您的位置:首页 > 编程语言 > Java开发

SpringMvc 之自动注解

2016-01-23 22:42 330 查看
 

 

<context:component-scan/> 元素会扫描指定的包极其所有子包,并查找能够自动注册为Spring Bean的类.base-package属性标识了<context:component-scan/> 元素所扫描的包

<context:component-scan base-package="org.test">
<context:exclude-filter type="annotation" expression="org.springframework.stereotype.Service" />
</context:component-scan>


 

会自动检测的标注Bean

@Component ---通用构造型注解

@Controller--标识为 spring mvc 控制器

@Repository --标识为数据仓储

@Service--标识为服务

 

 

过滤组件扫描

过滤器组件

<context:exclude-filter type="annotation" expression="org.springframework.stereotype.Service" />---不需要注册为bean
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: