Which of the following annotations is specifically used for injecting dependencies on setter methods?
- @Inject
- @Autowired
- @Resource
- @Setter
Among the provided options, the @Autowired annotation is specifically used for injecting dependencies on setter methods in Spring. When you apply @Autowired to a setter method, Spring will automatically inject the required dependencies into that setter method. The other annotations have different purposes, such as @Inject and @Resource are more generic dependency injection annotations, and @Setter is not a standard Spring annotation for dependency injection.
Loading...
Related Quiz
- Which annotation is primarily used in Spring Boot to mark the main class of your application?
- In a Spring Boot application, you are required to develop a feature where the response body should be customized based on the client's preference. How would you implement this feature using Spring Boot annotations?
- How can you create a shared bean that is not a singleton in Spring Boot?
- In Spring Boot, to capture and handle the MethodArgumentNotValidException, the _____ method in a controller advice can be used.
- In a Spring Cloud microservices architecture, _____ is primarily used for allowing services to discover each other.