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. angular.js - angular里的ui-view里,獲取當前頁面的狀態參數用$state.params,在vue里類似的語法是什么呢?2. 前端 - CSS3問題:請問-webkit-background-clip屬性,需要寫在background屬性后面嗎?3. javascript - 按鈕鏈接到另一個網址 怎么通過百度統計計算按鈕的點擊數量4. html5 - h5+中webview的show方法有延遲5. 微信開放平臺 - ios APP能不能打開微信然后通過微信跳轉到指定的URL?6. 淺談vue生命周期共有幾個階段?分別是什么?7. node.js - nodejs+express+vue8. Mysql啟動發生系統錯誤10679. nginx - vue-cli生成的項目打包發到服務器后怎么代理api?10. 大家好,我想請問一下怎么做搜索欄能夠搜索到自己網站的內容。
