spring 注解使用过程中的问题

报错信息:


available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}


报错说的很明白,预期至少有一个bean符合自动装配候选条件。依赖注释,

所以​:所以要么是 BeanB 不存在在 Spring 上下文中(比如没有标注 @ Component,@Repository,@Service, @Controller等注解) ,要么就是 BeanB 所在的包没有被 Spring 扫描到。

解决:

spring 使用遇到的问题_报错信息

spring 使用遇到的问题_java_02