Here we only want to exclude a class from certain classpath, say
com.abc.projectA.service.orderService.sectionA.orderService.class
However there is another class with same name but in different classpath
com.abc.projectA.service.orderService.sectionB.orderService.class
so that only filer by class name is not going to work.
But I tried the following method:
<context:component-scan base-package="com.abc">
<!--other filters-->
<!--.......-->
<context:exclude-filter expression="projectA\.service\.orderService\.sectionA\.orderService" type="regex" />
</context:component-scan>
It doesn't work. So I bet the <context:exclude-filter>
only valid on package level but not for specific class? If so, how to exclude a class from bean injection so that we can pick and choose with class to get wired with same class name?
Thanks in advance.
No, the exclude should work, the issue that you are having is probably that you are assuming that the path in regex will be pre-pended with the base-package which is not true..so just specify the full package
<context:component-scan base-package="com.abc">
<!--other filters-->
<!--.......-->
<context:exclude-filter expression="com\.abc\.projectA\.service\.orderService\.sectionA\.orderService" type="regex" />
</context:component-scan>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With