扩展MyBatis Generator
1. 将mybatis-generator-core
项目克隆到本地
https://github.com/li24361/mybatis-generator-core
2. 将mybatis-generator-core
打成jar包并存放到本地仓库中
cd mybatis-generator-core/ mvn install -Dmaven.test.skip=true
3. 修改pom.xml
<plugin> <groupId>org.mybatis.generator</groupId> <artifactId>mybatis-generator-maven-plugin</artifactId> <version>1.3.6</version> <configuration> <configurationFile>src/main/resources/generatorConfig.xml</configurationFile> <overwrite>true</overwrite> <verbose>true</verbose> </configuration> <dependencies> <dependency> <groupId>org.mybatis.generator</groupId> <artifactId>mybatis-generator-core</artifactId> <version>1.3.6</version> </dependency> <dependency> <groupId>com.haier.hairy</groupId> <artifactId>mybatis-generator-core</artifactId> <version>1.0.1</version> </dependency> </dependencies> </plugin>
4. 修改generatorConfig.xml
<commentGenerator type="org.mybatis.generator.internal.HairyCommentGenerator"> <property name="javaFileEncoding" value="UTF-8"/> <!--是否抑制所有的注释,默认为false--> <property name="suppressAllComments" value="false"/> <!--是否抑制注释中的时间,默认为false,这里改为true,不生成时间(如果生成时间,则每次都是新版本,每次都要提交)--> <property name="suppressDate" value="true"/> </commentGenerator>
5. 运行Mybatis Generator
在IDEA中,点击Edit Configurations –>添加一个Maven配置 –>录入Name GeneratorDAO –>Command Line录入:mybatis-generator:generate -e –>点击OK保存配置 –>点击或通过Alt+Shift+X运行这个Maven配置