文章详情页
java - spring自动扫描context:component-scan的简单问题
浏览:144日期: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. docker-machine添加一个已有的docker主机问题2. angular.js - grunt server 报错3. apache - nginx 日志删除后 重新建一个文件 就打不了日志了4. python - Pycharm的Debug用不了5. node.js - node express 中ajax post请求参数接收不到?6. java - tomcat服务经常晚上会挂,求解?7. java - 原生CGLib内部方法互相调用时可以代理,但基于CGLib的Spring AOP却代理失效,为什么?8. html - 用ajax提交表单后,返回验证数据在页面location.href跳转到主页,怎么传递session给主页9. 网站被黑,请教下大神,怎么对datebase.php内容加密。10. mysql - sql查询语句问题
排行榜
