java - spring自动扫描context:component-scan的简单问题
ringa_lee
ringa_lee 2017-04-18 10:52:27
0
1
377
<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等这些注解的类呢?

小白一个,谢谢各位大神帮忙解答一下了。

ringa_lee
ringa_lee

ringa_lee

Antworte allen(1)
PHPzhong

type 不要用 regex, 使用 annotation

<context:include-filter type="annotation" expression="org.springframework.stereotype.Service" />
Beliebte Tutorials
Mehr>
Neueste Downloads
Mehr>
Web-Effekte
Quellcode der Website
Website-Materialien
Frontend-Vorlage
Über uns Haftungsausschluss Sitemap
Chinesische PHP-Website:Online-PHP-Schulung für das Gemeinwohl,Helfen Sie PHP-Lernenden, sich schnell weiterzuentwickeln!