spring总结(十二)--spring通过注释配置bean(1)补充过滤器内容

spring总结(十二)--spring通过注释配置bean(1)补充

主要是对beans-annotation.xml配置文件做一下更加详细的说明

目录

resource-pattern属性

可以过滤特定的类,图中表示只扫描repository的类

此时再获取其他bean就会报错了

只获取userRepository就可以了

过滤器介绍

子节点+annotation属性

子节点+annotation属性

子节点+assignabel属性

子节点+assignabel属性


resource-pattern属性

可以过滤特定的类,图中表示只扫描repository的类

此时再获取其他bean就会报错了

只获取userRepository就可以了

过滤器介绍

一般只是使用annotation与assinabel

<context:exclude-filter>子节点+annotation属性

context:exclude-filter该子节点表示要排除在外的目标类

annotation属性指所有使用了xxx标注的类(这句话不知道正确不),

下图中表示:不包含使用了repository注释的类

这时在ioc容器中就获取不到userRepository的bean了

<context:include-filter>子节点+annotation属性

context:include-filter该子节点表示要包含的目标类

annotation属性指所有使用了xxx标注的类(这句话不知道正确不),

下图中表示:只扫描使用了Repository注释的类,其他注释的类不能被ioc容器加载

此时获取testObjec的bean是会报错了 

<context:exclude-filter>子节点+assignabel属性

context:exclude-filter该子节点表示要排除在外的目标类

assignabel属性指所有实现了该接口的类

下图中表示:不包括,实现了UserRepository接口的所有的类

此时再去获取userPepository的bean是会报错的

<context:include-filter>子节点+assignabel属性

context:include-filter该子节点表示只包含目标类

assignabel属性指所有实现了该接口的类

下图中表示:只包括,实现了UserRepository接口的所有的类

获取testObject会报错

猜你喜欢

转载自blog.csdn.net/lsx2017/article/details/81394559