java - spring自動掃描context:component-scan的簡單問題
問題描述
<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' />
相關文章:
1. docker images顯示的鏡像過多,狗眼被亮瞎了,怎么辦?2. angular.js - angularjs如何傳遞id給另一個視圖 根據id獲取json數據?3. 數據庫無法進入4. mysql - 記得以前在哪里看過一個估算時間的網站5. docker-compose 為何找不到配置文件?6. boot2docker無法啟動7. select - mysql怎么搜索一個字符串指定位置之后兩位8. python - linux怎么在每天的凌晨2點執行一次這個log.py文件9. android - E/dalvikvm: Could not find class java.nio.file.Path,10. 請問一下各位老鳥 我一直在學習獨孤九賤 現在是在tp5 今天發現 這個系列視頻沒有實戰
