mybatis generator 报错记录

今天在使用mybatis generator时出现了一个坑人的报错:

XML Parser Error on line 45: 元素类型为 "context" 的内容必须匹配 "(property*,plugin*,commentGenerator?,(connectionFactory|jdbcConnection),javaTypeResolver?,javaModelGenerator,sqlMapGenerator?,javaClientGenerator?,table+)"。 -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

在与官方说明核对和无数遍后发现拼写并没有错误,于是只能通过排除法来检查到底是哪个配置错了,最终定位到删除commentGenerator的配置就正常了,但是重新又核对了无数遍以后发现是没有拼写错误或其他笔误的。

<commentGenerator>
  <property name="suppressAllComments" value="false"/>
  <property name="addRemarkComments" value="true"/>
</commentGenerator>

于是陷入了沉思,突然想到原来在使用active mq时,有时由于配置顺序问题会产生报错,于是抱着试试看的态度将commentGenerator配置放到了context中classPathEntry后,即作为第二个自元素,再尝试运行,提示创建成功!

INFO] Generating Example class for table YMG_ENGINE
[INFO] Generating Record class for table YMG_ENGINE
[INFO] Generating Mapper Interface for table YMG_ENGINE
[INFO] Generating SQL Map for table YMG_ENGINE
[INFO] Saving file YmgEngineMapper.xml
[INFO] Saving file YmgEngineExample.java
[INFO] Saving file YmgEngine.java
[INFO] Saving file YmgEngineMapper.java
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------

因此可以知道,Mybatis Generator的配置是有顺序要求的,不知道作者为什么要这样设计,对于xml配置文件,不存在顺序逻辑的配置的顺序没有限制顺序的必要吧。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

EngineZhang

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值