Spring annotation-based container configuration context:include & exclude filters

Posted by lisak on Stack Overflow See other posts from Stack Overflow or by lisak
Published on 2011-01-03T12:41:36Z Indexed on 2011/01/03 12:54 UTC
Read the original article Hit count: 187

Filed under:
|

Hey,

first off I point to the similar question. I spent more than an hour to set this up, but PathMatchingResourcePatternResolver still scans everything.

I have one common.xml (that is imported from specific.xml) and a specific.xml bean definition file. The context is loaded from specific.xml. In common.xml there is this element:

<context:component-scan base-package="cz.instance.transl">
   <context:exclude-filter type="aspectj" 
        expression="cz.instance.transl.model..* &amp;&amp; cz.instance.transl.service..* &amp;&amp; cz.instance.transl.hooks..*"/>   
   </context:component-scan>

Where classes in packages like cz.instance.transl.service.* should not be subject of scanning, but everything else in here cz.instance.transl.* should be scanned through. But PathMatchingResourcePatternResolver marks everything as matching resources. It is the same with regex.

BTW: in xml style configuration, one can have many components that share a common.xml beans via "import resource" when loading context. How this is done when Annotation-based container configuration is used ?

© Stack Overflow or respective owner

Related posts about spring

Related posts about configuration