文章详情页
java - spring自动扫描context:component-scan的简单问题
浏览:125日期: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. java - 创建maven项目失败了 求解决方法2. java-se - 正在学习Java SE,为什么感觉学习Java就是在学习一些API。3. 一个走错路的23岁傻小子的提问4. python - 如何使用pykafka consumer进行数据处理并保存?5. javascript - SuperSlide.js火狐不兼容怎么回事呢6. node.js - 函数getByName()中如何使得co执行完后才return7. 运行python程序时出现“应用程序发生异常”的内存错误?8. 主从备份 - 跪求mysql 高可用主从方案9. javascript - git clone 下来的项目 想在本地运行 npm run install 报错10. python - django 里自定义的 login 方法,如何使用 login_required()
排行榜
