Win a copy of Zero to AI - A non-technical, hype-free guide to prospering in the AI era this week in the Artificial Intelligence and Machine Learning 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 ...
  • Campbell Ritchie
  • Liutauras Vilda
  • Paul Clapham
  • Bear Bibeault
  • Jeanne Boyarsky
  • Ron McLeod
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Jj Roberts
  • Stephan van Hulst
  • Carey Brown
  • salvin francis
  • Scott Selikoff
  • fred rosenberger

Qualifier annotation in Spring Boot does not work for the class that extends another one

Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have this hierarchy:

In the line below class A is injected not Y ( I need Y ):

Could you please tell me how to do in Spring Boot to inject class Y ?
The problem probably is that class A has @Primary annotation but does @Qualifier not have a priority ?

Ranch Hand
Posts: 95
VI Editor Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@Qualifier has indeed higher priority than @Primary. Works as expected for me with sample program according to your structure. Do you have all those classes in scope of Spring's component scan?

// Edit: You should have class A in scope of component scan, otherwise bean would not be found, but check if class Y is in scope of component scan.
Posts: 1955
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, Bronishlav,
Please try to add @Autowired to see if it can autowire your Y bean
Create symphonies in seed and soil. For this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
    Bookmark Topic Watch Topic
  • New Topic