I'm not sure that you can explicitly exclude packages using the <exclude-filter> filter, but I'm sure that using a regular expression filter will effectively get you there:
<context:component-scan base-package="com.example"> <context:exclude-filter type="regex" expression="com\.example\.ignore\..*"/> </context:component-scan>
To make it based on annotations, you must annotate every class that you want to exclude for integration tests, with something like @ com.example.annotation.ExcludedFromITests. Then the scan component will look like this:
<context:component-scan base-package="com.example"> <context:exclude-filter type="annotation" expression="com.example.annotation.ExcludedFromITests"/> </context:component-scan>
This is clearer because now you yourself have documented in the source code itself that the class is not intended to be included in the application context for integration tests.
Jonathan W May 23 '12 at 18:11 2012-05-23 18:11
source share