ssh之<context:component-scan base-package="com.xx" />

<context:component-scan/> 配置项不但启用了对类包进行扫描以实施注释驱动 Bean 定义的功能,

同时还启用了注释驱动自动注入的功能

( 即还隐式地在内部注册了 AutowiredAnnotationBeanPostProcessor 和 CommonAnnotationBeanPostProcessor ),


因此当使用 <context:component-scan/> 后,就可以将 <context:annotation-config/> 移除了。

 

<context:component-scan/> 的 base-package 属性指定了需要扫描的类包,类包及其递归子包中所有的类都会被处理。


作用就是所有的 hibernate 配置都不用在 hibernate.cfg.xml 里配置了,也不用一大堆的像Employee.hbm.xml,Person.hbm.xml。
原文地址:https://www.cnblogs.com/binggu/p/4607612.html