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. 求大神支招,php怎么操作在一個html文件的<head>標記內添加內容?2. 安裝了“PHP工具箱”,但只能以“游客”身份登錄3. 老師們php,插入數據庫mysql,都是空的,要怎么解決4. 怎么php怎么通過數組顯示sql查詢結果呢,查詢結果有多條,如圖。5. 在mybatis使用mysql的ON DUPLICATE KEY UPDATE語法實現存在即更新應該使用哪個標簽?6. 致命錯誤: Class ’appfacadeTest’ not found7. 在應用配置文件 app.php 中找不到’route_check_cache’配置項8. PHP類屬性聲明?9. php點贊一天一次怎么實現10. phpstady在win10上運行
