标签:用户 includes alt 数据库链接 cto 映射文件 als false open
向<dependencies>添加如下依赖 <!--mybatis启动器--> <dependency> <groupId>org.mybatis.spring.boot</groupId> <artifactId>mybatis-spring-boot-starter</artifactId> <version>2.1.2</version> </dependency> <!-- mysql驱动 --> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>8.0.19</version> </dependency> 向<build>标签下的<plugins>标签添加如下配置 <!--配置generator插件--> <plugin> <groupId>org.mybatis.generator</groupId> <artifactId>mybatis-generator-maven-plugin</artifactId> <version>1.3.7</version> <dependencies> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>8.0.19</version> </dependency> </dependencies> <!--指定配置文件的路径 ${project.basedir}项目根路径--> <configuration> <configurationFile>${project.basedir}/src/main/resources/generateConfig.xml</configurationFile> <verbose>true</verbose> <overwrite>true</overwrite> </configuration> </plugin> 向<build>标签添加如下配置 <resources> <resource> <directory>src/main/resources</directory> <includes> <include>**/*.xml</include> <include>**/*.yml</include> </includes> </resource> </resources>
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE generatorConfiguration PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN" "http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd"> <generatorConfiguration> <!-- 数据库驱动 --> <!--<properties resource="prop/jdbc-mysql.properties" />--> <!-- 指定数据连接驱动jar地址 --> <!--<classPathEntry location="${driverPath}" />--> <context id="context" targetRuntime="MyBatis3"> <!-- <plugin type="org.mybatis.generator.plugins.SerializablePlugin" /> <plugin type="org.mybatis.generator.plugins.EqualsHashCodePlugin" /> <plugin type="org.mybatis.generator.plugins.RenameExampleClassPlugin"> <property name="searchString" value="Example$" /> <property name="replaceString" value="Criteria" /> </plugin>--> <!-- 是否去掉生成出来的代码的注解 --> <commentGenerator> <property name="suppressAllComments" value="true" /> <property name="suppressDate" value="true" /> </commentGenerator> <!--数据库链接URL,用户名、密码 --> <jdbcConnection driverClass="com.mysql.cj.jdbc.Driver" connectionURL="jdbc:mysql://localhost:3306/springboot?characterEncoding=utf8&useSSL=false&serverTimezone=UTC&rewriteBatchedStatements=true" userId="root" password="root"> </jdbcConnection> <!--默认false 把jdbc DECIMAL 和 NUMERIC 类型解析为Integer,为true时,解析为java.math.BigDecimal--> <javaTypeResolver> <property name="forceBigDecimals" value="false" /> </javaTypeResolver> <!-- 生成pojo类的包名和位置 --> <javaModelGenerator targetPackage="com.example.springbootmybatis.pojo" targetProject=".\src\main\java"> <property name="enableSubPackages" value="true" /> <property name="trimStrings" value="true" /> </javaModelGenerator> <!-- 生成映射文件的包名和位置 --> <sqlMapGenerator targetPackage="mapper" targetProject=".\src\main\resources"> <property name="enableSubPackages" value="true" /> </sqlMapGenerator> <!-- 生成mapper的包名和位置 --> <javaClientGenerator type="XMLMAPPER" targetPackage="com.example.springbootmybatis.mapper" targetProject=".\src\main\java"> <property name="enableSubPackages" value="true" /> </javaClientGenerator> <!-- 要生成的表 tableName是数据库中的表名或视图名 domainObjectName是实体类名 --> <table tableName="users" domainObjectName=""></table> </context> </generatorConfiguration>
springboot maven mybatis generate插件的使用
标签:用户 includes alt 数据库链接 cto 映射文件 als false open
原文地址:https://www.cnblogs.com/activestruggle/p/12881840.html