• 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
  • Liutauras Vilda
  • Bear Bibeault
  • Junilu Lacar
  • Martin Vashko
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Scott Selikoff
  • salvin francis
  • Piet Souris

JPA Data Repository - 2 beans of type EntityManager found

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to set up a second data source in my Spring application. Below are the 2 configuration classes for the 2 data sources:

Primary data source config:


Second data source config




Until now I had Spring Auto configure the data source I had. My domain classes were generated by Database schemes in IntelliJ. So there is under the "Persistence Tab" in Intelli J one EntityManager that was there from the auto configured data source and two more for both aw and snd data sources.

I have several Repositories that are implemented like that:



Then there is for custom methods outside the CRUD Repo features an interface like that:


The implementation of that interface looks like that:



The Repos are used by Autowiring them:


I am getting this exception:




I would highly appreciate any help. I found nothing online that covered that problem. Only if EntitityManagers are implemented manually, which is not the case here.

 
Markus Kirschenbaum
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did anyone get an idea how to solve that?
I think it could be that the auto-configured bean conflicts with the bean manually created.
 
Markus Kirschenbaum
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Any help would be appreciated, this bug is really killing me...
 
Ranch Hand
Posts: 1772
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I noticed something in your code:

I think you can change either the bean name or the qualifier name. Since the names are the same, the container cannot tell which one to inject.
 
What could go wrong in a swell place like "The Evil Eye"? Or with this tiny ad?
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!