SpringBoot异常:Unsatisfied dependency expressed through field 'mapper'解决办法

编程入门 行业动态 更新时间:2024-10-28 04:27:39

今日改造SpringBoot项目时,发现部分子项目下的页面报错,异常信息显示为:创建Bean错误,底层的原因是无法找到Mapper文件的依赖关系,Spring无法自动装配,建议将自动装配设置为true

经过一番的了解与学习,通过添加@MapperScan即可解决,记录以备后用!

完整的异常信息为:

{success=false, errorMessage=Error creating bean with name 'XXXController': Unsatisfied dependency expressed through field 'XXXService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'XXXService': Unsatisfied dependency expressed through field 'mapper'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.XXX.modules.XXX.mapper.XXXMapper' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}, message=org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'XXXController': Unsatisfied dependency expressed through field 'XXXService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'XXXService': Unsatisfied dependency expressed through field 'mapper'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.XXX.modules.XXX.mapper.XXXMapper' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}}

解决办法

在SpringBoot的Application中添加@MapperScan注解,value=“"com.**.mapper"”

更多推荐

SpringBoot异常:Unsatisfied dependency expressed through field 'mapper'解决

本文发布于:2023-06-13 14:47:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1382897.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:解决办法   异常   Unsatisfied   SpringBoot   dependency

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!