0. git clone https://github.com/backkoms/mybatis-generator-comments.git, compile and package, install to local or delopy private server library.
1. pom.xml configuration
<build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>2.3.1</version> <configuration> <source>1.7</source> <target>1.7</target> <encoding>utf8</encoding> </configuration> </plugin> <plugin> <groupId>org.mybatis.generator</groupId> <artifactId>mybatis-generator-maven-plugin</artifactId> <version>1.3.2</version> <configuration> <configurationFile> ${basedir}/src/test/resources/conf/generatorConfig.xml </configurationFile> <overwrite>true</overwrite> </configuration> <dependencies> <dependency> <groupId>com.zhishi.mybatis</groupId> <artifactId>mybatis-generator-core</artifactId> <version>1.0.1</version> </dependency> </dependencies> </plugin> </plugins> </build>
2, generatorConfig.xml modification
<?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> <!-- jdbc path--> <classPathEntry location="C:\dev\Reporsitory\mysql\mysql-connector-java\5.1.38\mysql-connector-java-5.1.38.jar" /> <context id="context" targetRuntime="MyBatis3"> <plugin type="org.mybatis.generator.plugins.RenameExampleClassPlugin"> <property name="searchString" value="Example$" /> <property name="replaceString" value="Criteria" /> </plugin> <plugin type="org.mybatis.generator.plugins.CachePlugin"> <property name="cache_eviction" value="LRU" /> <property name="cache_flushInterval" value="60000" /> <property name="cache_readOnly" value="true" /> <property name="cache_size" value="1560" /> </plugin> <plugin type="org.mybatis.generator.plugins.EqualsHashCodePlugin"></plugin> <plugin type="org.mybatis.generator.plugins.SerializablePlugin"> <property name="suppressJavaInterface" value="false" /> </plugin> <commentGenerator type="org.mybatis.generator.internal.CustomeCommentGenerator"><!-- Database table comment generation--> <property name="javaFileEncoding" value="UTF-8" /> <!-- Whether to remove automatically generated comments true: yes: false: no --> <property name="suppressAllComments" value="false" /> <property name="suppressDate" value="false" /> </commentGenerator> <!-- Please fill in connectionURL, userId, password --> <jdbcConnection driverClass="com.mysql.jdbc.Driver" connectionURL="jdbc:mysql://192.168.1.102:3306/loan" userId="root" password="root" /> <!-- Generate persistent object --> <javaModelGenerator targetPackage="com.zhishi.domain" targetProject="src/test/java"> <property name="enableSubPackages" value="true" /> <property name="trimStrings" value="true" /> </javaModelGenerator> <!-- Generate mapper.xml file--> <sqlMapGenerator targetPackage="mapper/mybatis" targetProject="src/test/resources"> <property name="enableSubPackages" value="true" /> </sqlMapGenerator> <!-- Generate Mapper interface--> <javaClientGenerator targetPackage="com.zhishi.dal.mapper.credit" targetProject="src/main/java" type="XMLMAPPER"> <property name="enableSubPackages" value="true" /> </javaClientGenerator> <!-- Database table to be generated--> <table tableName="tb_trx_bank" domainObjectName="TrxBank"> <generatedKey column="tid" sqlStatement=" select replace(uuid(),'-','')" /> <!-- When the primary key is uuid, it is automatically generated --> </table> </context> </generatorConfiguration>
2. Enter the command line in Run as --> maven build .... --> Goals in eclipse: mybatis-generator:generate -e
3. View the generated file
/** * primary key * Table: tb_trx_bank * Corresponding field: tid */ private String tid; /** * Transaction Type * Table: tb_trx_bank * Corresponding field: type */ private String type;
This article is original content: please indicate the source for reprinting
[A ten-year code farmer's thoughts, scan the code to follow to get more exciting content]