码迷,mamicode.com
首页 > 移动开发 > 详细

Failed to load ApplicationContext

时间:2020-08-14 23:19:29      阅读:76      评论:0      收藏:0      [点我收藏+]

标签:报错   contex   alt   enc   eating   ted   which   mic   结构   

Failed to load ApplicationContext

今天遇到一个意料之外的错误,搜索半天发现都是很老的信息一无所获,最后自己仔细读取报错信息才发现的错误

Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘userServiceImpl‘: Unsatisfied dependency expressed through field ‘baseMapper‘; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type ‘com.bing.blog.mapper.UserMapper‘ available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}

因为之前使用mybatis-plus的代码自动生成器,在项目结构中有生成了 pojo包和mapper包,并且注解都配置好了,我猜想可能是因为spring容器中默认是单例模式,导致识别错误或者什么其他的错误

果然在删除多余的包后问题解决~

总结:

? springBoot也是约定大于配置,

@MapperScan("com.bing.mapper"),不能有多余的包

1、包的目录结构要固定

2、不能有多余的包

3、不能有重复的注入

技术图片

Failed to load ApplicationContext

标签:报错   contex   alt   enc   eating   ted   which   mic   结构   

原文地址:https://www.cnblogs.com/bingstudy/p/13501282.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!