Spring的注解分为两类:.net
1. 注册bean.对象
@Component , @Repository , @ Controller , @Service , @Configration 这些注解都是把你要实例化的对象转化成一个Bean,放在IoC容器中.get
2.使用bean.it
把已经在容器中装配好的Bean拿来用;io
如:@Autowired --> byType,class
@Resource --> byNAME 的方式获取Bean;容器
@Bean是放在方法上,使得被注注解的方法,产生一个Bean,而后交给Spring容器。service