spring mvc 中 component scan 配置详解
来源:互联网 发布:域名dns查询 编辑:程序博客网 时间:2024/06/08 09:08
在xml配置了这个标签后,spring可以自动去扫描base-pack下面或者子包下面的java文件,如果扫描到有@Component @Controller@Service等这些注解的类,则把这些类注册为bean
Spring 2.5引入了更多典型化注解(stereotype annotations): @Component、@Service和 @Controller。 @Component是所有受Spring管理组件的通用形式;而@Repository、@Service和 @Controller则是@Component的细化,用来表示更具体的用例(例如,分别对应了持久化层、服务层和表现层)。也就是说,你能用@Component来注解你的组件类,但如果用@Repository、@Service 或@Controller来注解它们,你的类也许能更好地被工具处理,或与切面进行关联。例如,这些典型化注解可以成为理想的切入点目标。当然,在Spring Framework以后的版本中, @Repository、@Service和 @Controller也许还能携带更多语义。如此一来,如果你正在考虑服务层中是该用 @Component还是@Service,那@Service显然是更好的选择。同样的,就像前面说的那样, @Repository已经能在持久化层中进行异常转换时被作为标记使用了。”
.<context:component-scan>提供两个子标签:
<context:include-filter>和<context:exclude-filter>各代表引入和排除的过滤。
component-scan 参数说明:
base-package:指定扫描的基本包名
use-default-filters:是否使用默认过滤条件,该值默认为true,即会扫描基本路径下的所有java类,并把匹配的java类注册成bean,此时为true,取base-package和include-filter的并集,如果为false,则base-package下的所有匹配的java类都不会被扫描,只有include-filter会被扫描到,
- spring mvc 中 component scan 配置详解
- spring中一些关键字@controller @service @component component-scan配置
- Spring配置 <context:component-scan/> <mvc:annotation-driven />
- Spring配置 <context:component-scan/> <mvc:annotation-driven />
- Spring配置 <context:component-scan/> <mvc:annotation-driven />
- Spring配置 <context:component-scan/> <mvc:annotation-driven />
- spring 配置context:component-scan
- context:component-scan 配置详解
- spring中context:component-scan
- spring applicationContext.xml 文件中<context:component-scan/>使用详解
- spring配置中annotation-config与component-scan区别
- Spring配置中<context:annotation-config> VS <context:component-scan>
- Spring MVC 解读---<context:component-scan/>
- [spring-mvc] <context:component-scan>使用说明
- spring mvc 中mvc:annotation-driven和context:component-scan区别
- spring注解注入:<context:component-scan>详解
- spring组件<context:component-scan>详解
- Spring <context:component-scan>使用详解
- 有哪些方法可以把ppt转成pdf的格式
- java三大框架
- 如何使用PLSQL创建表空间
- js 数字前面自动补零
- Xcode6中创建pch文件
- spring mvc 中 component scan 配置详解
- appcompat_v7/res/values-v21/themes_base.xml No resource found that matches the given name的解决方法
- 解决MYSQL不能远程连接的问题
- CRC码计算及校验原理的最通俗诠释
- 有哪些方法可以把ppt转成pdf的格式
- coco2dx3.x打包APK
- java 值传递和引用传递
- eclipse快捷键
- Beginning