1,Spring Framework 1.x 注解驱动启蒙时代
此时,Java5刚刚发布,开始支持Annotation,Spring1.2提供了==@Transactional和@ManagedResource==注解,但是此时Bean的装载还是通过XML配置文件的方式
<bean name="DemoSerivce"
class="com.ditian.example.spring.v1.DemoService01"/>
2,Spring Framework 2.x 注解驱动过渡时期
- Spring2.0 开始支持了@Required,@Repository,@Aspect等注解,同时也提升了XML的配置能力,可扩展编写XML文件的标签
- Spring2.5 提供了非常重要的注解@Autowired,@Qualifier,@Component,@Service,@Controller等注解,此时Spring还没有完全丢弃XML,还需要再XML中配置
<context:component-scan
base-package="com.ditian.example.spring.v2"></context:component-scan>
3,Spring Framework 3.x 注解驱动黄金时代
- Spring Framework3.x是一个里程碑的时代,提供了@Configuration注解,可以完全去XML化配置
- @ComponentScan(basePackages="")配置扫描的路径
- @Import导入其他配置类进行装载
- @EnableXXX可以模块化的装载
4,Spring Framework 4.x 注解驱动完善时代
Spring4.x 提供了@Conditional注解,可以自定义条件来决定Bean是否注册到容器中
5,Spring Framework 5.x 注解驱动成熟时代
中
5,Spring Framework 5.x 注解驱动成熟时代
Spring5.x支持了@Indexed注解,可以大大提升ComponentScan扫描的性能