Failed to load ApplicationContext

世事洞明皆学问,人情练达即文章。这篇文章主要讲述Failed to load ApplicationContext相关的知识,希望能为你提供帮助。
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】

Failed to load ApplicationContext

文章图片


    推荐阅读