classpath自动扫描

1.引入context命名空间

打开组件自动扫描配置项:<context:component-scan base-package="com.cn"/>

在路径底下寻找标注了@Component,@Service,@Controller,@Repository注解的类,并把这些类纳入Spring容器

@Service---------->标注业务层组件

@Controll---------->struts的action

@Reponsitory------>用于标注数据访问组件

@Component------->泛指组件

@Scope()------------------->作用域范围

原文地址:https://www.cnblogs.com/GodFather001/p/2288565.html