标签:
<context:component-scan base-package="com.vrv.paw.dao,com.vrv.paw.service,com.vrv.paw.action,install,com.vrv.paw.utils" />
或
<!-- 注解注入 --> <context:annotation-config></context:annotation-config> <context:component-scan base-package="com.vrv.paw.dao" /> <context:component-scan base-package="com.vrv.paw.service" /> <context:component-scan base-package="com.vrv.paw.action" /> <context:component-scan base-package="com.vrv.paw.utils" /> <context:component-scan base-package="install" />
@Component
@Scope("prototype")
public class TreeUtil{
.....
}
如果不想在xml文件中配置bean,我们可以给我们的类加上spring组件注解,然后再配置下spring的扫描器就可以实现bean的自动载入。
<context:component-scan base-package="com.xhlx.finance.budget" > <context:include-filter type="regex" expression=".service.*"/> </context:component-scan>
Spring组件扫描<context:component-scan/>使用详解
标签:
原文地址:http://www.cnblogs.com/liaojie970/p/5063620.html