解决mybatis generator无法覆盖XML
生活随笔
收集整理的這篇文章主要介紹了
解决mybatis generator无法覆盖XML
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
轉(zhuǎn)載自??解決mybatis generator無法覆蓋XML
今天發(fā)現(xiàn)mybatis generator maven plugin在重復(fù)生成的時候xml文件只會merge,不會覆蓋。
明明在pom.xml中配置了如下:
<configuration><configurationFile>src/main/resources/mybatis/generatorConfig.xml</configurationFile><verbose>true</verbose><overwrite>true</overwrite> </configuration>去github上查找與overwrite相關(guān)的issue,找到了這個提交。
上面的意思是:當(dāng)你取消了所有注釋,你在重復(fù)運行g(shù)enerator時在mapper.xml中會出現(xiàn)重復(fù)的元素。并且這個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
創(chuàng)作挑戰(zhàn)賽新人創(chuàng)作獎勵來咯,堅持創(chuàng)作打卡瓜分現(xiàn)金大獎總結(jié)
以上是生活随笔為你收集整理的解决mybatis generator无法覆盖XML的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 一代枭雄结局 一代枭雄最后怎样了
- 下一篇: 6、XML数据处理