解决mybatis generator无法覆盖XML
生活随笔
收集整理的这篇文章主要介绍了
解决mybatis generator无法覆盖XML
小编觉得挺不错的,现在分享给大家,帮大家做个参考.
转载自 解决mybatis generator无法覆盖XML
今天发现mybatis generator maven plugin在重复生成的时候xml文件只会merge,不会覆盖。
明明在pom.xml中配置了如下:
<configuration><configurationFile>src/main/resources/mybatis/generatorConfig.xml</configurationFile><verbose>true</verbose><overwrite>true</overwrite> </configuration>去github上查找与overwrite相关的issue,找到了这个提交。
上面的意思是:当你取消了所有注释,你在重复运行generator时在mapper.xml中会出现重复的元素。并且这个plugin可以解决这个问题,版本是1.3.7
去查看generatorConfiguration,确实配置了取消生成注释。
<!-- 配置生成器 --> <generatorConfiguration><properties resource="mybatis/jdbc.properties"/><context id="MyBatis" targetRuntime="MyBatis3" defaultModelType="flat"><!-- 不生成注释 --><commentGenerator><property name="suppressAllComments" value="true"/></commentGenerator>... ...<generatorConfiguration>那怎么既想取消注释又想覆盖XML文件生成呢?答案就是上面说的使用UnmergeableXmlMappersPlugin
在<context>下增加一个<plugin>
<!-- 配置生成器 --> <generatorConfiguration><properties resource="mybatis/jdbc.properties"/><context id="MyBatis" targetRuntime="MyBatis3" defaultModelType="flat"><!--覆盖生成XML文件--><plugin type="org.mybatis.generator.plugins.UnmergeableXmlMappersPlugin" /><!-- 不生成注释 --><commentGenerator><property name="suppressAllComments" value="true"/></commentGenerator>... ...<generatorConfiguration>GitHub地址:https://github.com/syoukaihou/sbsm
创作挑战赛新人创作奖励来咯,坚持创作打卡瓜分现金大奖总结
以上是生活随笔为你收集整理的解决mybatis generator无法覆盖XML的全部内容,希望文章能够帮你解决所遇到的问题。
- 上一篇: 一代枭雄结局 一代枭雄最后怎样了
- 下一篇: 6、XML数据处理