mybatis generator configuration reverse generation Entity simple add delete change and check of recommended
- 2020-05-19 04:50:25
- OfStack
The mybatis generator configuration reverse-generates the Entity simple add, delete, and modify verification example code as shown below:
<?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>
<!-- Database driven jar -->
<classPathEntry location="D:\.m2\repository\mysql\mysql-connector-java\5.1.38\mysql-connector-java-5.1.38.jar" />
<context id="DB2Tables" targetRuntime="MyBatis3">
<!-- Remove the comment -->
<commentGenerator>
<property name="suppressAllComments" value="true" />
</commentGenerator>
<!-- Database connection -->
<jdbcConnection driverClass="com.mysql.jdbc.Driver" connectionURL="jdbc:mysql://192.168.5.159:3306/ Database name "
userId=" The user name " password=" Do you know ">
</jdbcConnection>
<!-- The default false Java type resolver will always use java.math.BigDecimal if the database column is of type DECIMAL or NUMERIC. -->
<javaTypeResolver>
<property name="forceBigDecimals" value="false" />
</javaTypeResolver>
<!-- Generate entity class Specify the package name And the generated address You can customize the address, but the path does not exist and is not automatically created use Maven Generated in the target Directory, will be automatically created) -->
<javaModelGenerator targetPackage="com.heaboy. The package name .base.entity" targetProject=" The project name ">
<property name="enableSubPackages" value="false" />
<property name="trimStrings" value="true" />
</javaModelGenerator>
<!-- generate SQLMAP file -->
<sqlMapGenerator targetPackage="com.heaboy. The package name .mybatis" targetProject=" The project name ">
<property name="enableSubPackages" value="false" />
</sqlMapGenerator>
<!-- generate Dao file You can configure the type="XMLMAPPER" generate xml the dao implementation context id="DB2Tables" Modify the targetRuntime="MyBatis3" -->
<javaClientGenerator type="XMLMAPPER" targetPackage="com.heaboy. The package name .base.dao" targetProject=" The project name ">
<property name="enableSubPackages" value="false" />
</javaClientGenerator>
<!-- Corresponding database table mysql You can add a primary key and multiply it Field named Ignore a field, etc -->
<table tableName=" The name of the table " domainObjectName=" The generated entity name " enableCountByExample="false"
enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"
delimitIdentifiers="true">
<property name="useActualColumnNames" value="true" />
</table>
<table tableName=" The name of the table 2" domainObjectName=" The generated entity name 2" enableCountByExample="false"
enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false">
<property name="useActualColumnNames" value="true" />
</table>
</context>
</generatorConfiguration>