Spring Application context管理的对象
@Component 将对象注册到Spring Application context.,具体又可以细分为(为了开发者知道这个类的目的purpose):
@Service @Controller @Repository
其中@RestController是@Controller和@ResponseBody的结合
Component 与Bean的区别
-
@Bean使得不用再class上声明 (decouples the declaration of the bean from the class definition and lets you create and configure beans exactly how you choose.),官方的定义是:
Indicates that a method produces a bean to be managed by the Spring container.(通过方法来让Spring容器管理)
-
一般@Bean方法声明在@Configuration中