Spring 配置的方式

声明Bean的注解有:

  • @Component,没有明确的角色
  • @Service 在业务逻辑层使用, 基本质使用的@Component注解
  • @Repository 在数据访问层(dao层)使用
  • @Controller 在展现层使用
  •  @RestController

注入Bean的注解,一般情况下通用:

  • @Autowired, Spring提供的注解
  • @Inject, JSR-330提供的注解
  • @Resource, JSR-250提供的主机

以上三个注解都可注解在set方法或者属性上。

原文地址:https://www.cnblogs.com/liujianping/p/14921287.html