开发中的各种问题记录之Mybatis的坑Result Maps collection already contains value for com.bs.dao.UserMapper.BaseResu

首先说一下出现的问题:

严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'informationController': Unsatisfied dependency expressed through field 'informationDao'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'informationDao' defined in file [F:\JavaEE\employmentinformationsystem\target\classes\com\bs\dao\InformationDao.class]: Cannot resolve reference to bean 'sqlSessionFactory' while setting bean property 'sqlSessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in URL [file:/F:/JavaEE/employmentinformationsystem/target/classes/spring/springmvc.xml]: Invocation of init method failed; nested exception is org.springframework.core.NestedIOException: Failed to parse mapping resource: 'file [F:\JavaEE\employmentinformationsystem\target\classes\mapper\UserMapper.xml]'; nested exception is org.apache.ibatis.builder.BuilderException: Error parsing Mapper XML. The XML location is 'file [F:\JavaEE\employmentinformationsystem\target\classes\mapper\UserMapper.xml]'. Cause: java.lang.IllegalArgumentException: Result Maps collection already contains value for com.bs.dao.UserMapper.BaseResultMap
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:596)

这个就是问题,其余的内容也没有必要多粘,然后就说明一下是问题的原因是:

我的springmvc.xml中有这样的一句配置:

其作用就是将该目录下所有符合名称规范的mapper问价都扫描到容器中,然后进行相应的接口和标签的映射。

那么这样按照我的目录结构其扫描结果就是:

然后再看一下我的两个配置文件中的BaseResultMap的写法:

UserMapper.xml

InformationMapper.xml

对,问题就出在这里,出现的错也是因为已经有了BaseResultMap这个map,就不能再有了,所以把其中的一个换掉,就好了,这个问题很。。(口吐芬芳)。。

 

 

希望有帮助,欢迎指点。

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值