通过注解 配置 bean 泛型
2017-04-06 本文已影响86人
七宝qb
类上面加注解 () 中默认填写类对应 bean的 id
配置文件中 <context:component-scan base-package resource-pattern>
base-package 中可包含多个包,可通过‘空格’、‘,’ 分隔
<!--指定ioc容器包扫描的包
可以通过 resource-pattern 指定扫描的资源
如 resource-pattern="dao/*.class"
子节点 context:exclude-filter 不包含哪些
子节点 context:include-filter 一般要和 use-default-filters(默认true) 属性配合使用
子节点下的属性
type:1、annotation 注解的类名 import上的那个
2、assignable bean类的类名
-->
<context:component-scan base-package="com.springTest.beanAnnotation"
use-default-filters="false">
<context:include-filter type="assignable"
expression="com.springTest.beanAnnotation.controller"/>
</context:component-scan>
使用@Autowire 装配bean

泛型
