插件:
<plugin>
<groupId>org.mybatis.generator</groupId>
<artifactId>mybatis-generator-maven-plugin</artifactId>
<version>1.3.2</version>
<configuration>
<verbose>true</verbose>
<overwrite>true</overwrite>
</configuration>
</plugin>
配置generatorConfig.xml
<?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> <!-- 引入配置文件 url/resource--> <properties resource="syscfg.properties" /> <!-- 指定数据连接驱动jar地址--> <classPathEntry location="F:/maven-workSpace/com/***/extend/oracle/ojdbc14/10.2.0.2.0/ojdbc14-10.2.0.2.0.jar" /> <!-- 一个数据库一个context --> <context id="infoGuardian" targetRuntime="MyBatis3"> <!-- "MyBatis3Simple" --> <!-- 注释 --> <commentGenerator> <property name="suppressAllComments" value="false" /> <!-- 是否取消注释 --> <property name="suppressDate" value="false" /> <!-- 是否生成注释代时间戳--> <property name="useStatementNamespaces" value="true" /> </commentGenerator> <!-- jdbc连接 --> <jdbcConnection driverClass="oracle.jdbc.driver.OracleDriver" connectionURL="${dataSource.jdbcUrl}" userId="inasdb" password="Boco2017" /> <!-- 类型转换 --> <javaTypeResolver> <property name="forceBigDecimals" value="false" /> </javaTypeResolver> <!-- 生成实体类地址 --> <javaModelGenerator targetPackage="com.***.base.entity" targetProject="src/main/java"> <property name="enableSubPackages" value="true" /> <!-- 是否针对string类型的字段在set的时候进行trim调用 --> <property name="trimStrings" value="true" /> </javaModelGenerator> <!-- 生成mapxml文件 --> <sqlMapGenerator targetPackage="com.***.base.dao.mapper" targetProject="src/main/java"> <property name="enableSubPackages" value="false" /> </sqlMapGenerator> <!-- 生成mapxml对应client,也就是接口dao --> <javaClientGenerator targetPackage="com.***.base.dao" implementationPackage="com.***.base.dao" targetProject="src/main/java" type="XMLMAPPER"> <property name="enableSubPackages" value="false" /> </javaClientGenerator>
<!-- 这里配置表名 -->
<table schema="" tableName="***_****_***" ></table></ context > </ generatorConfiguration >
命令行:
mybatis-generator:generate -e