如果需要@Autowired一个类 那么,首先看该类是否有@Component注解,其次,看是否在主程序所在包或其子包下,不是的话需要: 加上:@ComponentScan(basePackages = {“完整包名”}) 相关文章: