在進行表結構調整后,需要通過插件生成mybatis的mapper.xml文件時,默認是不會覆蓋原有的xml內容,而是merge內容。經常需要手動刪除后再生成,非常麻煩。
通過如下配置可以實現以上功能。
在generatorConfig.xml配置中,增加如下配置
<plugin type="org.mybatis.generator.plugins.UnmergeableXmlMappersPlugin" />
注:網上查到資料,如下方式可以覆蓋,但是經驗證,不生效,暫時還不知道原因
在pom.xml的配置overwrite
插件配置
<plugin>
<groupId>org.mybatis.generator</groupId>
<artifactId>mybatis-generator-maven-plugin</artifactId>
<version>1.4.0</version>
<configuration>
<overwrite>true</overwrite>
<verbose>true</verbose>
</configuration>
</plugin>