No qualifying bean of type 'XXXXX' available

简介: 该文档描述了Spring框架中`org.springframework.beans.factory.NoSuchBeanDefinitionException`异常的处理方法,该异常是因为无法找到类型为`com.weblog.auth.mapper.UserMapper`的bean导致。解决办法包括在对应的Mapper上添加`@Mapper`注解,并在启动类上添加`@MapperScan`注解以扫描包含Mapper接口的文件夹。
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'userServiceImpl': Unsatisfied dependency expressed through field 'baseMapper': No qualifying bean of type 'com.weblog.auth.mapper.UserMapper' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}

Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.weblog.auth.mapper.UserMapper' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}

错误:org.springframework.beans.factory.NoSuchBeanDefinitionException。没有在factory找到已经定义的bean

解释:No qualifying bean of type 'XXXX' available。具体是哪一个没有找到,根据com.weblog.auth.mapper.UserMapper找到提示的包

引起原因:在使用自动注入的时候,没有找到对应的bean

image.png

解决方案:

  1. 在对应的Mapper上添加@Mapper注解

image.png

  1. 在启动类上添加@MapperScan注解,指定到mapper所在的文件夹(推荐)

image.png



目录
相关文章
|
Java 数据库连接 mybatis
Consider defining a bean of type ‘com.example.democrud.democurd.usermapper.DaoMapper‘ in your config
Consider defining a bean of type ‘com.example.democrud.democurd.usermapper.DaoMapper‘ in your config
181 0
|
2月前
|
XML 数据格式
Could not autowire. No beans of ‘VideoDao‘ type found.
Could not autowire. No beans of ‘VideoDao‘ type found.
|
4月前
No qualifying bean of type [com.XX.mapper.SysNameMapper ] found for dependency
No qualifying bean of type [com.XX.mapper.SysNameMapper ] found for dependency
88 0
|
10月前
解决requried a bean of type xxx的问题(可能原因之一)
解决requried a bean of type xxx的问题(可能原因之一)
235 0
|
10月前
|
Java 容器 Spring
No qualifying bean of type或Unsatisfied dependency expressed through field ‘XXXService‘或@Autowired 注入
No qualifying bean of type或Unsatisfied dependency expressed through field ‘XXXService‘或@Autowired 注入
85 0
|
11月前
|
Java 编译器
解决NoSuchBeanDefinitionException: No qualifying bean of type ‘bean.User‘ available
解决NoSuchBeanDefinitionException: No qualifying bean of type ‘bean.User‘ available
139 0
|
Java Spring 容器
No qualifying bean of type ‘java.lang.String‘ available: expected at least 1 bean which qualifies
No qualifying bean of type ‘java.lang.String‘ available: expected at least 1 bean which qualifies
884 0
No qualifying bean of type ‘java.lang.String‘ available: expected at least 1 bean which qualifies
记一个SpringBoot中属性注入失败的问题Consider defining a bean of type ''' in your configuration...
记一个SpringBoot中属性注入失败的问题Consider defining a bean of type ''' in your configuration...
277 0
|
NoSQL Java Redis
5. 成功解决:Could not autowire. No beans of 'RedisConnectionFactory' type found.
今天建了一个新项目,使用 Spring Boot 整合 Redis 时,IDEA 被提醒“Could not autowire. No beans of 'RedisConnectionFactory' type found. ”错误,意思是不能自动装配“RedisConnectionFactory”。
2818 1
|
Java
springboot3 解决:Could not autowire. No beans of ‘JavaMailSender‘ type found
因为 spring-boot-starter-mail 默认使用某些包发生了变化,在 2.2.xx 版本前后不一,解决对应bug
403 0