mybatis逆向工程生成pojo,dao,想启动测试一下,发现启动报错,
ERROR 9112 — [ restartedMain] o.m.spring.mapper.MapperFactoryBean
- Error while adding the mapper ‘interface
cn.marblog.bwcar.dao.ActivityCarMapper’ to configuration.
org.apache.ibatis.builder.BuilderException: Error parsing Mapper XML. The XML location is ‘cn/marblog/bwcar/dao/ActivityCarMapper.xml’. Cause: java.lang.IllegalArgumentException: Result Maps collection already contains value for cn.marblog.bwcar.dao.ActivityCarMapper.BaseResultMap
![]()
![]()
![]()
Caused by: java.lang.IllegalArgumentException: Result Maps collection
already contains value for
cn.marblog.bwcar.dao.ActivityCarMapper.BaseResultMap at
org.apache.ibatis.session.Configuration S t r i c t M a p . p u t ( C o n f i g u r a t i o n . j a v a : 872 ) [ m y b a t i s − 3.4.6. j a r : 3.4.6 ] a t o r g . a p a c h e . i b a t i s . s e s s i o n . C o n f i g u r a t i o n StrictMap.put(Configuration.java:872) ~[mybatis-3.4.6.jar:3.4.6] at org.apache.ibatis.session.Configuration StrictMap.put(Configuration.java:872) [mybatis−3.4.6.jar:3.4.6]atorg.apache.ibatis.session.ConfigurationStrictMap.put(Configuration.java:844)
~[mybatis-3.4.6.jar:3.4.6] at
org.apache.ibatis.session.Configuration.addResultMap(Configuration.java:626)
~[mybatis-3.4.6.jar:3.4.6] at
org.apache.ibatis.builder.MapperBuilderAssistant.addResultMap(MapperBuilderAssistant.java:214)
~[mybatis-3.4.6.jar:3.4.6] at
org.apache.ibatis.builder.ResultMapResolver.resolve(ResultMapResolver.java:47)
~[mybatis-3.4.6.jar:3.4.6] at
org.apache.ibatis.builder.xml.XMLMapperBuilder.resultMapElement(XMLMapperBuilder.java:285)
~[mybatis-3.4.6.jar:3.4.6] at
org.apache.ibatis.builder.xml.XMLMapperBuilder.resultMapElement(XMLMapperBuilder.java:252)
~[mybatis-3.4.6.jar:3.4.6] at
org.apache.ibatis.builder.xml.XMLMapperBuilder.resultMapElements(XMLMapperBuilder.java:244)
~[mybatis-3.4.6.jar:3.4.6] at
org.apache.ibatis.builder.xml.XMLMapperBuilder.configurationElement(XMLMapperBuilder.java:116)
~[mybatis-3.4.6.jar:3.4.6] … 30 common frames omitted
起初以为是没加注解,但是加上注解也不行,把逆向工程生成的文件删掉项目可以跑起来,所以应该是生成文件的问题,查了半天发现是有的表重复了,Result Maps collection already contains value for cn.marblog.bwcar.dao.ActivityCarMapper.BaseResultMap
所以在配置文件的 jdbcConnection标签中加入
<property name="nullCatalogMeansCurrent" value="true"/>
删除原来的文件, 重新生成一下文件即可。