bean无法自动装配

文章详细描述了一个在SpringBoot应用中集成Mybatis时遇到的错误,具体涉及到bean的创建失败,特别是SaleLeadsMapper,原因在于ResultMap集合已经在XML映射文件中存在。解决方案包括检查注解、MapperScan配置、避免代码生成器重复生成以及查阅相关报错教程来解决ResultMap冲突问题。
摘要由CSDN通过智能技术生成

报错记录

报错详情

 Error creating bean with name 'saleLeadsController': Unsatisfied dependency expressed through field 'saleLeadsService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'saleLeadsService': Unsatisfied dependency expressed through field 'saleLeadsMapper'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'saleLeadsMapper' defined in file [E:\IdeaProjects\kindo-oms\server\target\classes\com\kindo\oms\mapper\SaleLeadsMapper.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 [org/mybatis/spring/boot/autoconfigure/MybatisAutoConfiguration.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 [E:\IdeaProjects\kindo-oms\server\target\classes\mapper\SaleLeadsMapper.xml]'; nested exception is org.apache.ibatis.builder.BuilderException: Error parsing Mapper XML. The XML location is 'file [E:\IdeaProjects\kindo-oms\server\target\classes\mapper\SaleLeadsMapper.xml]'. Cause: java.lang.IllegalArgumentException: Result Maps collection already contains value for com.kindo.oms.mapper.SaleLeadsMapper.BaseResultMap

总结
1 mapper,service,controller层注解检查,
2 查看启动类mapper
@MapperScan(basePackages = “com.kindo.oms.mapper”)
3 代码生成器重复生成,不会覆盖原有的,会在xml里面往后面加一样的 <resultMap 》…,仔细检查xml
4 查错教程------Mybatis报错 Result Maps collection already contains value for 原因汇总
https://blog.csdn.net/flystarfly/article/details/106195858

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值