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 for Mac 創建的dnsmasq容器連不上/不工作的問題2. 關docker hub上有些鏡像的tag被標記““This image has vulnerabilities””3. 我何時應該在Java中使用JFrame.add(component)和JFrame.getContentPane()。add(component)4. docker - 如何修改運行中容器的配置5. docker鏡像push報錯6. html5和Flash對抗是什么情況?7. javascript - 請指條明路,angular的$event,在select中卻是undefined?8. 利用IPMI遠程安裝centos報錯!9. javascript - 在 model里定義的 引用表模型時,model為undefined。10. phpstudy8.1沒集成mysql-front

網公網安備