mybatis-generator生成多次重复代码
原因
xxx:3306的mysql服务里,有多个数据库。
不同数据库里面的表名相同,导致互相影响,重复生成
tips:哪怕在url里面配置了数据库名,依然会重复
解决方案
在mapper-generator-config.xml文件中增加如下配置
<!--生成对应表及类名-->
<table tablename="表名" domainobjectname="brandandproject"
enablecountbyexample="false" enableselectbyexample="false" enableupdatebyexample="false"
enabledeletebyexample="false" catalog="数据库名">
<property name="useactualcolumnnames" value="false"></property>
<property name="ignorequalifiersatruntime" value="true"></property>
</table>
最关键的就是catalog属性:
指定你想要 逆向工程代码 的 表所在的数据库名

总结
以上为个人经验,希望能给大家一个参考,也希望大家多多支持代码网。
发表评论