This week's book giveaway is in the HTML Pages with CSS and JavaScript forum.
We're giving away four copies of Testing JavaScript Applications and have Lucas da Costa on-line!
See this thread for details.
Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Java Config same annotation bean in multiple config classes

 
Ranch Hand
Posts: 120
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to switch to java config from xml.

We have a core library, and then implementations that use the core library. We also have webapp and cli in each implementation. I am trying to modularize the config. We do use component scanning for certain packages. I am running into a circular dependency issue in the config classes. I need to inject the same @Component into beans created in multiple java config classes. My configs are as follows:







What would be the best way to solve this?

1 option would be to not use component scanning. Others?
 
Rj Ewing
Ranch Hand
Posts: 120
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry, this is in the wrong forum. Can someone please move this to the Spring forum?
 
Rj Ewing
Ranch Hand
Posts: 120
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So after a bit more digging, this has to do with me trying to override a bean in the java config.





I am trying to override the SettingsBean, however CoreAppConfig uses SettingsBean to create MyBean. I think this is why I am getting a BeanCurrentlyInCreationException error. Any ideas how to resolve this?
 
Sheriff
Posts: 9671
42
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can't override beans like that. Ideally you should make the parameter to SettingsBean dynamic like ${PROD_NAME} or something similar. You can then specify this value using environment variable...
 
Rj Ewing
Ranch Hand
Posts: 120
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
okay, I ended up putting the SettingsBean in a separate config, then using @PropertySource(), i retrieve the param for SettingsBean
 
Consider Paul's rocket mass heater.
    Bookmark Topic Watch Topic
  • New Topic