博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
解决 mybatis-generator-maven-plugin 中 overwrite 配置无效的问题
阅读量:6936 次
发布时间:2019-06-27

本文共 2009 字,大约阅读时间需要 6 分钟。

问题

使用 mybatis-generator-maven-plugin 重复生成代码时, xml 文件不会覆盖, 而是每次累加.

目的

每次生成时都会生成全新的 xml 文件并覆盖旧的

配置

pom.xml

org.mybatis.generator
mybatis-generator-maven-plugin
${mybatis-generator.version}
src/main/resources/mybatis/generator.xml
true
true
mysql
mysql-connector-java
6.0.6
com.softwareloop
mybatis-generator-lombok-plugin
1.0-SNAPSHOT

build 插件中已经加入覆盖配置, 然后并没有什么卵用

src/main/resources/mybatis/generator.xml
true
true

搜索

在官方 issues 中以 overwrite 为关键字进行搜索, 发现两个有价值的信息

第一个链接有一句话

The overwrite property is only used for generated Java files. It should not affect XML files at all. XML files should always be merged.Have you configured a comment generator with suppressAllComment=true? If so, that would be the cause of this behavior. The XML merge won't delete old elements if the comments are removed.

原来 overwrite 配置只是为了覆盖 java 类, xml 文件是不受这个控制的

第二链接是一个 pull request, 作者添加了一个插件, 新特性刚好就是解决这个问题了, 遗憾的是这个 pr 虽然已经合入 master 分支了, 但是并没有上传到中央仓库, 1.3.7 还只是一个 SNAPSHOT 版本.

解决

自己从 拉下源码 mvn install 一下就可以用了.

安装到本地仓库后还需要修改自己项目中依赖的版本号, 然后在配置文件中添加一个插件, 问题解决.

转载地址:http://scbnl.baihongyu.com/

你可能感兴趣的文章
快速构建Windows 8风格应用9-竖直视图
查看>>
Chrome浏览器设置不缓存
查看>>
YII2出现SQLSTATE[HY000] [2002] No such file or director
查看>>
搭建nginx+3*tomcat环境 实现session共享
查看>>
毕业只是开始:你准备好了吗?
查看>>
交互式自动化脚本模板
查看>>
顺丰和菜鸟对用户数据寸土不让 战争平息需监管层
查看>>
软件测试LR通用性能分析流程
查看>>
如何升级phpmyadmin
查看>>
hibernate添加时间问题
查看>>
深入浅出CChart 每日一课——第十三课 似曾相识之云图,乱花渐欲迷人眼
查看>>
Oracle操作的部分ddl语句
查看>>
Excel 中使用SQL 语句查询数据(四)
查看>>
序列动作Sequence
查看>>
SpringMVC 架构、原理
查看>>
Spring Shiro
查看>>
小蚂蚁学习数据结构(10)——树的基本介绍
查看>>
linux apache
查看>>
在CMD命令行下关闭进程的命令
查看>>
puppet学习笔记之安装与配置
查看>>