Mybatis generator configures the reverse generation of Entity simple addition, deletion, modification and search example code is as follows:
<?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 Driver 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 comments--> <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="user name" password="You know"> </jdbcConnection> <!--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 the entity class specifies the package name and the generated address (you can customize the address, but the path does not exist, will not be automatically created. Generate it in the target directory using Maven, and will be automatically created) --> <javaModelGenerator targetPackage="com.heaboy.package name.base.entity" targetProject="Project name"> <property name="enableSubPackages" value="false" /> <property name="trimStrings" value="true" /> </javaModelGenerator> <!--Generate SQLMAP file--> <sqlMapGenerator targetPackage="com.heaboy.package name.mybatis" targetProject="Project name"> <property name="enableSubPackages" value="false" /> </sqlMapGenerator> <!--Generate Dao files, you can configure type="XMLMAPPER" to generate xml dao implementation context id="DB2Tables" to modify targetRuntime="MyBatis3" --> <javaClientGenerator type="XMLMAPPER" targetPackage="com.heaboy.package name.base.dao" targetProject="Project name"> <property name="enableSubPackages" value="false" /> </javaClientGenerator> <!--The corresponding database table mysql can add primary key self-increment field name ignore a certain field, etc. --> <table tableName="table name" domainObjectName="generated entity name" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false" delimitIdentifiers="true"> <property name="useActualColumnNames" value="true" /> </table> <table tableName="table name 2" domainObjectName="generated entity name 2" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"> <property name="useActualColumnNames" value="true" /> </table> </context></generatorConfiguration>
The above is the mybatis generator configuration reverse generation Entity. I hope it will be helpful to you. If you have any questions, please leave me a message and the editor will reply to you in time. Thank you very much for your support to Wulin.com website!