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.
15 Replies
⌛
This post has been reserved for your question.
Hey @lucifer7303! Please useTIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here./close
or theClose 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.
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
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.oh ok got it
it works after fixing the code but now when i try it with @Qualifier("parrot"), it doesnt work
do beans added by @component annotation have no name?
this doesnt work too
Try to add the
@Autowired
annotation together with @Qualifier
aight that works
thanks mate
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.
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
Well, you can have multiple cdi implementations at the same time.
@Qualifier
is not bound to spring only.
@Autowired
is bound to spring.oh ok i didnt know that
Post Closed
This post has been closed by <@613989956607803393>.