Java Spring Help regarding @AutoWired

why doesnt this work there is a bean of Parrot.class but why doesnt AutoWired inject it to parrot identifier i read the documentation of AutoWired and it should do this according to it.
No description
15 Replies
JavaBot
JavaBot6mo ago
This post has been reserved for your question.
Hey @lucifer7303! Please use /close or the Close Post button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.
TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.
lucifer7303
lucifer7303OP6mo ago
the 18th line of code definitely shows that there is a bean of Parrot.class but when i print the identifier parrot which is supposed to be injected into by Spring, it is null
Peter Rader
Peter Rader6mo ago
The Javadoc of Autowired points out: Fields are injected right after construction of a bean, before any config methods are invoked. App is never constructed as a Bean.
lucifer7303
lucifer7303OP6mo ago
oh ok got it it works after fixing the code but now when i try it with @Qualifier("parrot"), it doesnt work
lucifer7303
lucifer7303OP6mo ago
No description
lucifer7303
lucifer7303OP6mo ago
do beans added by @component annotation have no name?
lucifer7303
lucifer7303OP6mo ago
No description
lucifer7303
lucifer7303OP6mo ago
this doesnt work too
Peter Rader
Peter Rader6mo ago
Try to add the @Autowired annotation together with @Qualifier
lucifer7303
lucifer7303OP6mo ago
aight that works thanks mate
JavaBot
JavaBot6mo ago
If you are finished with your post, please close it. If you are not, please ignore this message. Note that you will not be able to send further messages here after this post have been closed but you will be able to create new posts.
lucifer7303
lucifer7303OP6mo ago
but cant really understand the reason behind it maybe i shouldnt dig so much into shit and just use whats required or maybe the vice versa and understand everything idk
Peter Rader
Peter Rader6mo ago
Well, you can have multiple cdi implementations at the same time. @Qualifier is not bound to spring only. @Autowired is bound to spring.
lucifer7303
lucifer7303OP6mo ago
oh ok i didnt know that
JavaBot
JavaBot6mo ago
Post Closed
This post has been closed by <@613989956607803393>.
Want results from more Discord servers?
Add your server