概要
记录一下使用@Autowired注入时出现Could not autowire. No beans of ‘xxx’ type found.无法自动连线,未找到xxx类型的bean的问题
这个问题对编译运行没有影响,只是IDEA没有找到对应的bean。
应该是没有正确使用注解,参考:autoWired注解报错 Could not autowire. No beans of ‘xxxService‘ type found.
不同的包下使用不同的注解注入
@Repository:代表dao层
@Component:惯用实体类
@Service : 用于service层
@Controller : 用于Controller
上面的注解作用都一样,只是在不同的包下尽量使用对应的注解
新手上路,如有错误欢迎指正