@Component and @Bean do two quite different things, and shouldn't be confused. @Component (and @Service and @Repository) are used to auto-detect and auto-configure beans using classpath scanning. There's an implicit one-to-one mapping between the ann…
from: http://stackoverflow.com/questions/10604298/spring-component-versus-bean http://stackoverflow.com/questions/27091553/are-bean-and-component-annotations-the-same-but-for-different-targets-in-sprin @Component and @Bean do two quite different thin…
Spring帮助我们管理Bean分为两个部分,一个是注册Bean,一个装配Bean.完成这两个动作有三种方式,一种是使用自动配置的方式.一种是使用JavaConfig的方式,一种就是使用XML配置的方式. @Compent 作用就相当于 XML配置 @Component public class Student { private String name = "lkm"; public String getName() { return name; } public void setN…