文章詳情頁
java - spring自動掃描context:component-scan的簡單問題
瀏覽:159日期: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. Span標簽2. css - 求推薦適用于vue2的框架 像bootstrap這種類型的3. docker-machine添加一個已有的docker主機問題4. css - 關于div自適應問題,大家看圖吧,說不清5. 關docker hub上有些鏡像的tag被標記““This image has vulnerabilities””6. SessionNotFoundException:會話ID為null。調用quit()后使用WebDriver嗎?(硒)7. android新手一枚,android使用httclient獲取服務器端數據失敗,但是用java工程運行就可以成功獲取。8. angular.js使用$resource服務把數據存入mongodb的問題。9. java - Collections類里的swap函數,源碼為什么要新定義一個final的List型變量l指向傳入的list?10. python - django如何每次調用標簽的時候都取隨機數據
排行榜
