文章詳情頁
java - spring自動掃描context:component-scan的簡單問題
瀏覽:157日期: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. html5 - ElementUI table中el-table-column怎么設置百分比顯示。2. python - 使用readlines()方法讀取文件內容后,再用for循環遍歷文件與變量匹配時出現疑難?3. 對mysql某個字段監控的功能4. css3 - less或者scss 顏色計算的知識應該怎么學?或者在哪里學?5. 注冊賬戶文字不能左右分離6. javascript - table列過多,有什么插件可以提供列排序和選擇顯示列的功能7. css - 網頁div區塊 像蘋果一樣可左右滑動 手機與電腦8. javascript - 數組的過濾和渲染9. html - vue項目中用到了elementUI問題10. JavaScript事件
排行榜
