文章詳情頁
java - spring自動掃描context:component-scan的簡單問題
瀏覽:258日期: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. javascript - immutable配合react提升性能?2. javascript - sublime快鍵鍵問題3. css - 寫頁面遇到個布局問題,求大佬們幫解答,在線等,急!~4. Apache 已經把網站根目錄的改為allow from all了,但是服務器還是不能訪問?5. javascript - 移動端上不能實現拖拽布局嗎?6. 實現bing搜索工具urlAPI提交7. vue.js - Vue 如何像Angular.js watch 一樣監聽數據變化8. phpstudy8.1支持win11系統嗎?9. 配置Apache時,添加對PHP的支持時語法錯誤10. javascript - nodejs關于進程間發送句柄的一點疑問
排行榜

網公網安備