table of Contents
Generation command
java -jar generator.jar -configfile generator.xml -overwrite
oracle configuration
<?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>
<classPathEntry location="ojdbc14.jar" />
<context id="context1">
<commentGenerator>
<property name="suppressAllComments" value="true" />
</commentGenerator>
<jdbcConnection driverClass="oracle.jdbc.driver.OracleDriver" connectionURL="jdbc:oracle:thin:@139.219.199.9:1521:coaltest" userId="fw_data_user" password="123456" />
<javaModelGenerator targetPackage="com" targetProject="src" />
<sqlMapGenerator targetPackage="com" targetProject="src" />
<javaClientGenerator type="XMLMAPPER" targetPackage="com" targetProject="src">
<property name="enableSubPackages" value="true"/>
</javaClientGenerator>
<table tableName="T_PF_CHECK_RESULT" domainObjectName="PfCheckResult"
delimitIdentifiers="true" delimitAllColumns="true"
enableCountByExample="false" enableUpdateByExample="false"
enableDeleteByExample="false" enableSelectByExample="false"
selectByExampleQueryId="false">
</table>
</context>
</generatorConfiguration>
mysql configuration
<?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>
<classPathEntry location="mysql-connector-java-8.0.13.jar" />
<context id="context1">
<commentGenerator>
<property name="suppressAllComments" value="true" />
</commentGenerator>
<jdbcConnection driverClass="com.mysql.cj.jdbc.Driver" connectionURL="jdbc:mysql://192.168.2.163:3306/gpftest" userId="root" password="123456" />
<javaModelGenerator targetPackage="com" targetProject="src" />
<sqlMapGenerator targetPackage="com" targetProject="src" />
<javaClientGenerator type="XMLMAPPER" targetPackage="com" targetProject="src">
<property name="enableSubPackages" value="true"/>
</javaClientGenerator>
<table tableName="t_user" domainObjectName="User"
delimitIdentifiers="true" delimitAllColumns="true"
enableCountByExample="false" enableUpdateByExample="false"
enableDeleteByExample="false" enableSelectByExample="false"
selectByExampleQueryId="false">
</table>
</context>
</generatorConfiguration>
Configuration updates:
<?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>
<classPathEntry location="mysql-connector-java.jar" />
<context id="context1">
<property name="beginningDelimiter" value="`"/>
<property name="endingDelimiter" value="`"/>
<commentGenerator>
<property name="suppressAllComments" value="true" />
</commentGenerator>
<jdbcConnection driverClass="com.mysql.cj.jdbc.Driver" connectionURL="jdbc:mysql://ip:3306/dbname" userId="" password="">
<property name="useInformationSchema" value="true"/>
</jdbcConnection>
<javaModelGenerator targetPackage="com" targetProject="src" />
<sqlMapGenerator targetPackage="com" targetProject="src" />
<javaClientGenerator type="XMLMAPPER" targetPackage="com" targetProject="src">
<property name="enableSubPackages" value="true"/>
</javaClientGenerator>
<table tableName="base_meta_instance_resource"
domainObjectName="BaseMetaInstanceResource"
delimitIdentifiers="true"
delimitAllColumns="true"
enableSelectByPrimaryKey="true"
enableInsert="true"
enableDeleteByPrimaryKey="true"
enableUpdateByPrimaryKey="true">
</table>
</context>
</generatorConfiguration>
Solve the problem
mapper.xml generated duplicate codes
Solution: xml configuration, remove the code below
<property name="suppressAllComments" value="true"/>
Unable to generate selectByPrimaryKey, deleteByPrimaryKey methods
The mysql-driven version reduced to 5.x, has not been verified
or
Add the following tag (effective, recommended)
<jdbcConnection driverClass="com.mysql.cj.jdbc.Driver" connectionURL="" userId="" password="">
<property name="useInformationSchema" value="true"/>
</jdbcConnection>