spring中注解说明

<context:component-scan base-package="com.test.feizhou" use-default-filters="false">  

1 base-package:要扫描的包

2 use-default-filters:

false:表示不要使用默认的过滤器,

true: 描指定包下标有@Service,@Component,@Repository,@Controller的注解的全部类,并注册成bean。

 

 3 context:component-scan节点允许有两个子节点<context:include-filter>和<context:exclude-filter>。filter标签的type和表达式说明如下:

 Filter TypeExamples ExpressionDescription
annotationorg.example.SomeAnnotation符合SomeAnnoation的target class
assignableorg.example.SomeClass指定class或interface的全名
aspectjorg.example..*Service+AspectJ語法
regexorg\.example\.Default.*Regelar Expression
customorg.example.MyTypeFilterSpring3新增自訂Type,實作org.springframework.core.type.TypeFilter

案列

<context:include-filter type="regex" expression="com\.example\.test\.[^.]+(Controller|Service)"/>

要扫描的类:以Controller或者Service结束的类。

使用注解的案例

<context:include-filter type="annotation" expression="org.springframework.stereotype.Controller"/>   

 

转载于:https://www.cnblogs.com/feiZhou/p/9343981.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值