mybatis-generator-maven-plugin 1.4.0-SNAPSHOT版本集成通用Mapper生成的Mapper接口没有继承通用Mapper接口
-
您好,我在使用mybatis-generator-maven-plugin 1.3.7版本时通过在generatorConfig.xml中配置domainObjectRenamingRule来重命名生成的实体类时发现实体类没有应用驼峰命名,例如数据库中表名为sys_user_info,在domainObjectRenamingRule中将sys前缀去除掉后生成的实体类为Userinfo而不是UserInfo。
-
随后我将mybatis-generator-maven-plugin切换到1.4.0-SNAPSHOT版本,然后发现您之前编写的TkMyBatis3Impl类中重写IntrospectedTable类中的calculateJavaClientAttributes方法报了错误,setDAOImplementationType、setDAOInterfaceType这些方法在1.4.0-SNAPSHO版本中已经不在了。
-
所以我将generatorConfig.xml中context标签下的targetRuntime属性设置为MyBatis3Simple后,发现生成的Mapper接口没有继承通用Mapper接口。
可以指定MapperPlugin插件, 并设置mappers属性, 如:
<context id="Mysql" targetRuntime="MyBatis3Simple" defaultModelType="flat">
<plugin type="tk.mybatis.mapper.generator.MapperPlugin">
<property name="mappers" value="tk.mybatis.mapper.common.Mapper"/>
</plugin>
...
@qrqhuang
嗯,我在里面配置了MapperPlugin插件,并且设置了mapper属性。
如果使用的是mybatis-generator-maven-plugin的1.4.0-SNAPSHOT版本的话,那么生成的Mapper接口不会继承通用Mapper接口。
如果使用的是mybatis-generator-maven-plugin的1.3.7或以下版本的话就没有这个问题。
我使用SNAPSHOT + MyBatis3Simple + MapperPlugin 可以正常继承接口。
mybatis-generator-maven-plugin 1.4.0 中IntrospectedTable 接口有改动, 等正式版发布了再由作者迭代吧;
别急着用快照版。
@qrqhuang 嗯,我在里面配置了
MapperPlugin插件,并且设置了mapper属性。 如果使用的是mybatis-generator-maven-plugin的1.4.0-SNAPSHOT版本的话,那么生成的Mapper接口不会继承通用Mapper接口。 如果使用的是mybatis-generator-maven-plugin的1.3.7或以下版本的话就没有这个问题。
亲测1.3.6版本可用 等下个release再做测试吧,tk肯定也会适配1.4.0的
1.4.0-SNAPSHOT版本报错: Caused by: java.lang.ClassNotFoundException: org.mybatis.generator.api.dom.xml.Element ...... at org.mybatis.generator.internal.ObjectFactory.internalClassForName (ObjectFactory.java:141) at org.mybatis.generator.internal.ObjectFactory.createInternalObject (ObjectFactory.java:177) at org.mybatis.generator.internal.ObjectFactory.createCommentGenerator (ObjectFactory.java:238) at org.mybatis.generator.config.Context.getCommentGenerator (Context.java:262) at org.mybatis.generator.codegen.mybatis3.model.BaseRecordGenerator.getCompilationUnits (BaseRecordGenerator.java:53) at org.mybatis.generator.codegen.mybatis3.IntrospectedTableMyBatis3Impl.getGeneratedJavaFiles (IntrospectedTableMyBatis3Impl.java:176) at org.mybatis.generator.config.Context.generateFiles (Context.java:446) at org.mybatis.generator.api.MyBatisGenerator.generate (MyBatisGenerator.java:269) at org.mybatis.generator.api.MyBatisGenerator.generate (MyBatisGenerator.java:189)
1.4.0 Release了一年多了,还是没有适配 ~
2022年才支持。。