问答详情
源自:8-2 整合MyBatis - 实现基于mybatis的CRUD功能

启动报错 Error creating bean with name 'myBatisCRUDController'

2020-12-20 17:15:58.592  WARN 12008 --- [  restartedMain] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'myBatisCRUDController': Unsatisfied dependency expressed through field 'userService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'userServiceImpl': Unsatisfied dependency expressed through field 'userMapper'; nested exception is

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'sysUserMapper' defined in file [F:\xiangmu3\Xin\FuQiang\Springboot_1\download_resource\SpringbootDemo\demo\demo\target\classes\com\example\demo\mapper\SysUserMapper.class]: Unsatisfied dependency expressed through bean property 'sqlSessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in class path resource [tk/mybatis/mapper/autoconfigure/MapperAutoConfiguration.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: 'file [F:\xiangmu3\Xin\FuQiang\Springboot_1\download_resource\SpringbootDemo\demo\demo\target\classes\mapper\AaaMapper.xml]'; nested exception is org.apache.ibatis.builder.BuilderException: Error parsing Mapper XML. Cause: java.lang.IllegalArgumentException: Result Maps collection already contains value for com.example.demo.mapper.AaaMapper.BaseResultMap
2020-12-20 17:15:58.599  INFO 12008 --- [  restartedMain] com.alibaba.druid.pool.DruidDataSource   : {dataSource-1} closed
2020-12-20 17:15:58.605  INFO 12008 --- [  restartedMain] o.apache.catalina.core.StandardService   : Stopping service [Tomcat]
2020-12-20 17:15:58.628  INFO 12008 --- [  restartedMain] ConditionEvaluationReportLoggingListener :

...
Disconnected from the target VM, address: '127.0.0.1:14700', transport: 'socket'

Process finished with exit code 0

提问者:小蜗牛有大理想 2020-12-20 17:23

个回答

  • 小蜗牛有大理想
    2020-12-20 17:29:57

    问题已经解决,自己在generatorConfig.xml 中配置了两个不同的table,一个不用的table  生成了pojo,mapper以及*mapper.xml,但是项目中没有引用无用的table,所以报错,在  generatorConfig.xml 除去那个无用的table即可。

    除去:

    <table tableName="aaa"></table>