文章详情页
java - spring自动扫描context:component-scan的简单问题
浏览:241日期:2024-01-13 09:38:51
问题描述
<context:component-scan base-package='personal.test' use-default-filters='false' ><context:include-filter type='regex' expression='personal.test.manager.*'/><context:include-filter type='regex' expression='personal.test.apiserver.process.sdkapi.*'/> </context:component-scan>
我看都说<context:component-scan>这个扫描,只会扫描@Component @Controller@Service等这些注解的类。
可是,我上面的配置,personal.test.manager这个包下的所有类都被实例化了。
很多类并没有加注解。
我怎样设置才能只扫面@Component @Controller@Service等这些注解的类呢?
小白一个,谢谢各位大神帮忙解答一下了。
问题解答
回答1:type 不要用 regex, 使用 annotation
<context:include-filter type='annotation' expression='org.springframework.stereotype.Service' />
标签:
java
相关文章:
1. dockerfile - [docker build image失败- npm install]2. Docker for Mac 创建的dnsmasq容器连不上/不工作的问题3. docker-compose中volumes的问题4. boot2docker无法启动5. docker网络端口映射,没有方便点的操作方法么?6. docker gitlab 如何git clone?7. dockerfile - 我用docker build的时候出现下边问题 麻烦帮我看一下8. 关docker hub上有些镜像的tag被标记““This image has vulnerabilities””9. docker images显示的镜像过多,狗眼被亮瞎了,怎么办?10. docker不显示端口映射呢?
排行榜

网公网安备