How do <context:include-filter> and <context:exclude-filter> work in Spring?

Viewed 51844

I have several services:

  • example.MailService
  • example.LDAPService
  • example.SQLService
  • example.WebService
  • example.ExcelService

annotated with @Service annotation. How can I exclude all services except one?


For example I want to use only MailService. I use the following configuration:

<context:component-scan base-package="example">
    <context:include-filter type="aspectj" expression="example..MailService*" />
    <context:exclude-filter type="aspectj" expression="example..*Service*" />
</context:component-scan>

but now all services are excluded.

Why all services are excluded if exists one rule to include MailService?

3 Answers
Related