• Post Reply Bookmark Topic Watch Topic
  • New Topic

filtering component scans (doesn't work)  RSS feed

Ranch Hand
Posts: 378
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have this configuration in my bean.xml

I have a few services in com.example.engine.manager package:

but I wanted to disable some service like DealManager and the rest of services will be still running.
Therefore I put this "exclude-filter" into bean.xml, but it doesn't work.

any wrong with my syntax (i ran it without error though) or any that I don't know?

I tried search with google but the results are not helpful.

Any master here can give me a clue ?

Thanks in advance.
Posts: 17314
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, I can't help with regex, I don't know regex, nor want to know it. ;)

You can do a couple of approaches. I see that you turned off the default filters which are includes for @Service, @Repository etc.

I do know your order might not make it work, where the first include included your DealManager and therefore the exclude after is overwritten, or maybe the other way around.

One approach I like in this scenario is to create my own set of Annotations and use those in your class and filters where type="Annotations" (Always make sure you include package for your Annotation in the value)

I had three web apps all sharing the same Core project that had Services that in some apps needed and in others didn't. And I couldn't come up with a good filter at that time. Since then and after I left that company, I realized that creating my own Annotation, one for each app, I could put those on those classes and write a clean filter and get exactly the classes I want.

So say I have an app called Moo and another called Bark, I would create an @Moo and a @Bark annotation, I could annotate those annotations with @Service or @Component, then put one or both on Managers that I need in that particular app. Then just

for the Bark application.

That is one possible solution.

With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!