mybatis-generator使用Maven Plugin管理和生成代码
之前用批处理文件.bat来执行命令生成mybatis的相关文件,但是假如用Mac或者Linux,还得改配置文件,那么灵活一点,通过Maven安装插件,来管理jar和执行命令
pom.xml
<pluginManagement><plugins><plugin><groupId>org.eclipse.m2e</groupId><artifactId>lifecycle-mapping</artifactId><version>1.0.0</version><configuration><lifecycleMappingMetadata><pluginExecutions><!-- copy-dependency plugin --><pluginExecution><pluginExecutionFilter><groupId>org.apache.maven.plugins</groupId><artifactId>maven-dependency-plugin</artifactId><versionRange>[1.0.0,)</versionRange><goals><goal>copy-dependencies</goal></goals></pluginExecutionFilter><action><ignore /></action></pluginExecution><!-- mybatis-generator-plugin --><pluginExecution><pluginExecutionFilter><groupId>org.mybatis.generator</groupId><artifactId>mybatis-generator-maven-plugin</artifactId><versionRange>[1.3.2,)</versionRange><goals><goal>generate</goal></goals></pluginExecutionFilter><action><ignore /></action></pluginExecution></pluginExecutions></lifecycleMappingMetadata></configuration></plugin></plugins></pluginManagement>