elcadro
elcadro

Reputation: 1492

Spring components scan with multiple directories

I need to add these directories to my app. This actually works:

<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"/>

Bu I'd like to know how could I make this with just one line of code. Something like:

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

Any help or ideas? Thanks a lot!

Upvotes: 0

Views: 3947

Answers (2)

elcadro
elcadro

Reputation: 1492

Sorry, but actually the solution I posted before, works fine:

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

Upvotes: 0

Rigg802
Rigg802

Reputation: 2674

<!-- 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>

Upvotes: 1

Related Questions