Spring组件扫描多个目录

时间:2013-01-25 12:28:34

标签: spring-mvc portlet

我需要将这些目录添加到我的应用中。这实际上有效:

<context:component-scan base-package="web.controllers"/>
<context:component-scan base-package="web.controllers.gec"/>
<context:component-scan base-package="web.controllers.gec.costs"/>
<context:component-scan base-package="web.controllers.gec.pay"/>

我想知道我怎么能用一行代码才能做到这一点。类似的东西:

 <context:component-scan base-package="web.controllers">
       <context:include-filter type="regex" expression=".*.*"/>
 </context:component-scan>

任何帮助或想法?非常感谢!

2 个答案:

答案 0 :(得分:1)

<!-- The controllers are autodetected POJOs labeled with the @Controller annotation. -->
<context:component-scan base-package="com.company.app" use-default-filters="false">
    <context:include-filter expression="org.springframework.stereotype.Controller" type="annotation"/>
</context:component-scan>

答案 1 :(得分:0)

很抱歉,但实际上我之前发布的解决方案,运行正常:

<context:component-scan base-package="web.controllers">
   <context:include-filter type="regex" expression=".*.*"/>
</context:component-scan>