标签:XML div generator false detail mode com splay name
使用mybatis的代码生成工具:mybatis-generator,如果自动生成的BO都有公共的属性,则可以指定这些BO继承父类(父类中定义公共属性)
1、定义父类
注意:属性public,不要使用private,让子类BO可以直接操作它
2、BO打jar包,并在mybatis-generator-maven-plugin中指定依赖
注意:一定要把依赖的BO先打jar包
1 <plugin> 2 <groupId>org.mybatis.generator</groupId> 3 <artifactId>mybatis-generator-maven-plugin</artifactId> 4 <version>1.3.2</version> 5 <configuration> 6 <configurationFile>${basedir}/src/main/resources/mybatis-generator.xml</configurationFile> 7 <verbose>true</verbose> 8 <overwrite>true</overwrite> 9 </configuration> 10 <dependencies> 11 <dependency> 12 <groupId>org.mybatis.generator</groupId> 13 <artifactId>mybatis-generator-core</artifactId> 14 <version>1.3.3.MDX</version> 15 </dependency> 16 <!-- Mybatis自动生成的BO继承公共父类,因此依赖jar --> 17 <dependency> 18 <groupId>com.omniprimeinc.acct</groupId> 19 <artifactId>acct-services</artifactId> 20 <version>1.0.0-SNAPSHOT</version> 21 </dependency> 22 </dependencies> 23 </plugin>
3、mybatis-generator配置中指定父类
<property name="rootClass" value="com.XX.XX.XX.model.CommonDO"/>
1 <table tableName="fundin" 2 enableCountByExample="false" enableUpdateByExample="false" 3 enableDeleteByExample="false" enableSelectByExample="true" 4 selectByExampleQueryId="false"> 5 <property name="rootClass" value="com.omniprimeinc.acct.services.model.CommonDO"/> 6 <generatedKey column="id" sqlStatement="SELECT LAST_INSERT_ID()"/> 7 </table>
4、生成
参考:
Mybatis自动生成的BO对象继承公共父类(BO中过滤掉公共属性)
标签:XML div generator false detail mode com splay name
原文地址:https://www.cnblogs.com/huahua035/p/10262610.html