I know this is an old question, but I haven't come across any answers that solved this problem for me so I'll provide my solution.
Note: I thought the issue may have been this, but my issue wasn't related to implementing the same interface twice. Using @Qualitier
did make my issue go away, but it was a bandage and not a proper solution so I didn't settle with that.
BACKGROUND
I'm tasked with maintaining an old project that has gone through different versions of spring and only updated for separate modules, so things needed refactoring, to say the least. I had initially gotten the duplicate bean issue and tinkering with things changed the issue back and forth between OP's issue and the duplicate bean issue even though there was only one bean; navigating to the duplicate beans always went to the same class.
THE ISSUE
The issue was present on a @Repository
class that was @Autowired
in a @Service
class which was also had the @ComponentScan
annotation. I noticed that I also had a spring application-config.xml
that was doing a context:component-scan
on the base package, which I believe was the original approach in older versions of Spring. I was in the process of making a new branch by taking parts of an old branch and a newer branch in a support project that was used in different projects that were developed over several years and that is why there was such a mix-and-match of methodologies.
SIMPLE SOLUTION
Since the more modern approach of using @ComponentScan
was already implemented I just removed the application-config.xml
and the issue was solved.
@SuppressWarnings("SpringJavaInjectionPointsAutowiringInspection")
– Adagiettoalt + enter
on warning, thenrigth arrow
and selectSuppress for class
. Idea will add right@SuppressWarnings
annotation automatically – Dutchman@Suppress("SpringJavaInjectionPointsAutowiringInspection")
i.e. not@SuppressWarnings
– Marmawke