Meaningless Drivel is fun!*
The moose likes Spring and the fly likes Multiple annotation based context configuration Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Multiple annotation based context configuration" Watch "Multiple annotation based context configuration" New topic
Author

Multiple annotation based context configuration

Adolfo Eloy
Ranch Hand

Joined: Mar 21, 2009
Posts: 146

Hello,

I'm developing a spring based application which I'd like to organize in separated projects like follows:

books-service: provides all services binded to repositories working with some relational database
books-web: provides all controllers and web resources

books-service has a configuration using java class annotated with @Configuration which scans for br.com.books.service package
books-web has a configuration using java class annotated with @Configuration which scans for br.com.books.controller package

When I set the base package to @ComponentScan with br.com.books I have all requests being executed twice because beans were created twice.
So to solve this, I'm using @ComponentScan.Filter as follows:

Configuration for web app:


Configuration for services app:


So even using this configuration, my services are being executed twice.
Does anybody knows what's happening here?

Thanks in advance

Adolfo Eloy


Adolfo Eloy
Software Developer
OCPJP 6
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Multiple annotation based context configuration