转载请注明来源-作者@loongshawn:http://blog.csdn.net/loongshawn/article/details/51656699
相关文章:
- 《Mybatis异常-SQLErrorCodes loaded: DB2, Derby, H2, HSQL, Informix, MS-SQL, MySQL, Oracle, PostgreSQL》
- 《Mybatis异常-SQL执行没反应,但oracle单独执行正常》
- 《Mybatis异常-java.lang.IllegalArgumentException: No enum constant org.apache.ibatis.type.JdbcType.NUMBE》
- 《MyBatis批量更新》
- 《MyBatis JdbcType 与Oracle、MySql数据类型对应关系详解》
- 《程序员需要知道的各类官方文档地址》
运行环境
SpringBoot
Mybatis异常摘要
2016-06-13-11-48 [main] [org.mybatis.spring.mapper.MapperFactoryBean] [ERROR] - Error while adding the mapper 'interface com.autonavi.dao.impl.mapper.pms.DemandStatisticMapper' to configuration.
java.lang.RuntimeException: Error parsing Mapper XML. Cause: java.lang.IllegalArgumentException: Result Maps collection already contains value for com.autonavi.dao.impl.mapper.pms.DemandStatisticMapper.demandResultMap
Mybatis异常详细
2016-06-13-11-48 [main] [org.mybatis.spring.mapper.MapperFactoryBean] [ERROR] - Error while adding the mapper 'interface com.autonavi.dao.impl.mapper.pms.DemandStatisticMapper' to configuration.
java.lang.RuntimeException: Error parsing Mapper XML. Cause: java.lang.IllegalArgumentException: Result Maps collection already contains value for com.autonavi.dao.impl.mapper.pms.DemandStatisticMapper.demandResultMap
at org.apache.ibatis.builder.xml.XMLMapperBuilder.configurationElement(XMLMapperBuilder.java:113)
at org.apache.ibatis.builder.xml.XMLMapperBuilder.parse(XMLMapperBuilder.java:88)
at org.apache.ibatis.builder.annotation.MapperAnnotationBuilder.loadXmlResource(MapperAnnotationBuilder.java:138)
at org.apache.ibatis.builder.annotation.MapperAnnotationBuilder.parse(MapperAnnotationBuilder.java:111)
at org.apache.ibatis.binding.MapperRegistry.addMapper(MapperRegistry.java:60)
at org.apache.ibatis.session.Configuration.addMapper(Configuration.java:532)
at org.mybatis.spring.mapper.MapperFactoryBean.checkDaoConfig(MapperFactoryBean.java:95)
at org.springframework.dao.support.DaoSupport.afterPropertiesSet(DaoSupport.java:44)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1613)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1550)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:302)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:298)
at org.springframework.beans.factory.support.AbstractBeanFactory.getTypeForFactoryBean(AbstractBeanFactory.java:1418)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.getTypeForFactoryBean(AbstractAutowireCapableBeanFactory.java:788)
at org.springframework.beans.factory.support.AbstractBeanFactory.isTypeMatch(AbstractBeanFactory.java:541)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doGetBeanNamesForType(DefaultListableBeanFactory.java:387)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanNamesForType(DefaultListableBeanFactory.java:362)
at org.springframework.beans.factory.BeanFactoryUtils.beanNamesForTypeIncludingAncestors(BeanFactoryUtils.java:187)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:1006)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:964)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:862)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:494)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:298)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1186)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:537)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:302)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:298)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:370)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1095)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:990)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:504)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:302)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:298)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:198)
at org.springframework.context.annotation.MBeanExportConfiguration.setupServer(MBeanExportConfiguration.java:108)
at org.springframework.context.annotation.MBeanExportConfiguration.mbeanExporter(MBeanExportConfiguration.java:87)
at org.springframework.context.annotation.MBeanExportConfiguration$$EnhancerBySpringCGLIB$$3387e37d.CGLIB$mbeanExporter$1(<generated>)
...
异常产生原因
Caused by: java.lang.IllegalArgumentException: Result Maps collection already contains value for com.autonavi.dao.impl.mapper.pms.DemandStatisticMapper.demandResultMap
由于DemandStatisticMapper.xml文件中存在重名对象,保持名称不要一样即可正常启动。
异常排查
XML中是这样写的
<sql id="statisticItemChildren2DemandColumn">
date,
number_pass,
number_reject,
rate
</sql>
<sql id="statisticItemChildren2DemandColumn">
id,
date,
number_pass,
number_reject,
rate
</sql>
由于DemandStatisticMapper.xml文件中存在重名对象,保持名称不要一样即可正常启动。
<sql id="statisticItemChildren2DemandColumn">
date,
number_pass,
number_reject,
rate
</sql>
<sql id="statisticItemChildren2Demand1Column">
id,
date,
number_pass,
number_reject,
rate
</sql>