B is of course correct, but the reason why C is correct is because the default required setting of Autowired is 'true'. If no bean is found, a org.springframework.beans.factory.NoSuchBeanDefinitionException is thrown, which is a RuntimeException.
A is not correct as the Fields are injected right after construction of a bean, before any config methods are invoked.
D is incorrect as you can't annotate a class.
E is incorrect as Autowired is not supported in BeanPostProcessor or BeanFactoryPostProcessor, so you can't inject a reference in them using Autowired.
Here is my reference: https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/beans/factory/annotation/Autowired.html
A and B, per Autowired documentation.
Autowired Fields
Fields are injected right after construction of a bean, before any config methods are invoked. Such a config field does not have to be public.
Autowired Methods
Config methods may have an arbitrary name and any number of arguments; each of those arguments will be autowired with a matching bean in the Spring container. Bean property setter methods are effectively just a special case of such a general config method. Such config methods do not have to be public.
E is not correct
Note that actual injection is performed through a BeanPostProcessor which in turn means that you cannot use @Autowired to inject references into BeanPostProcessor or BeanFactoryPostProcessor types. Please consult the javadoc for the AutowiredAnnotationBeanPostProcessor class (which, by default, checks for the presence of this annotation).
https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/beans/factory/annotation/Autowired.html
A voting comment increases the vote count for the chosen answer by one.
Upvoting a comment with a selected answer will also increase the vote count towards that answer by one.
So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.
Azuni
Highly Voted 11 months agoAzuni
10 months, 2 weeks agoTolo01
Most Recent 11 months, 1 week agoqqoo
11 months, 4 weeks agorhuanca
1 year, 2 months agoqulyt
1 year, 5 months agorhuanca
1 year, 3 months agofaciorys
1 year, 6 months ago