解决方案:此错误是因为用Mybatis -代码自动生成(generatorConfig.xml)工具,对应的mapper的xml文件中生成了两个resultMap(BaseResultMap),删除其中一个,或删除此xml文件,重新生成。

造成的原因:Mybatis -代码自动生成(generatorConfig.xml)工具可能重复执行了。

异常(错误)信息:java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at org.springframework.boot.maven.AbstractRunMojo$LaunchRunner.run(AbstractRunMojo.java:527)
    at java.lang.Thread.run(Thread.java:745)
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'batchLensListener': Unsatisfied dependency expressed through field 'batchLensService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'batchLensServiceImpl': Unsatisfied dependency expressed through field 'richUserLogMapper'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'richUserLogMapper' defined in URL [jar:file:/C:/Users/zhen.zhang/.m2/repository/com/huifu/dclmsbatch/dclmsbatch-dal/1.0-SNAPSHOT/dclmsbatch-dal-1.0-SNAPSHOT.jar!/com/huifu/dclmsbatch/dal/mapper/RichUserLogMapper.class]: Cannot resolve reference to bean 'sqlSessionTemplate' while setting bean property 'sqlSessionTemplate'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'sqlSessionTemplate' defined in class path resource [com/huifu/dclmsbatch/dal/HikariCPDatesourceConfig.class]: Unsatisfied dependency expressed through method 'sqlSessionTemplate' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in class path resource [com/huifu/dclmsbatch/dal/HikariCPDatesourceConfig.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.apache.ibatis.session.SqlSessionFactory]: Factory method 'sqlSessionFactory' threw exception; nested exception is org.springframework.core.NestedIOException: Failed to parse mapping resource: 'URL [jar:file:/C:/Users/zhen.zhang/.m2/repository/com/huifu/dclmsbatch/dclmsbatch-dal/1.0-SNAPSHOT/dclmsbatch-dal-1.0-SNAPSHOT.jar!/com/huifu/dclmsbatch/dal/mapper/RichLoginUserMapper.xml]'; nested exception is org.apache.ibatis.builder.BuilderException: Error parsing Mapper XML. The XML location is 'URL [jar:file:/C:/Users/zhen.zhang/.m2/repository/com/huifu/dclmsbatch/dclmsbatch-dal/1.0-SNAPSHOT/dclmsbatch-dal-1.0-SNAPSHOT.jar!/com/huifu/dclmsbatch/dal/mapper/RichLoginUserMapper.xml]'. Cause: java.lang.IllegalArgumentException: Result Maps collection already contains value for com.huifu.dclmsbatch.dal.mapper.RichLoginUserMapper.BaseResultMap
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:588)
    at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88)
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:366)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1272)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:553)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:312)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:308)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:761)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:867)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:543)
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122)
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:693)
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:360)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:303)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1118)
    at com.huifu.dclmsbatch.application.BootApplication.main(BootApplication.java:24)

Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐