Question 1 of 30
In a Spring application, you are tasked with implementing a service that requires the use of multiple beans, each with different scopes. You need to ensure that a singleton bean is injected into a prototype bean, and that the prototype bean is created each time it is requested. What is the best approach to achieve this while maintaining the correct lifecycle management of the beans?
Use the `@Lookup` annotation on the prototype bean to retrieve the singleton bean.
Define both beans in the configuration class and use `@Autowired` for injection.
Use `@Scope("prototype")` on the singleton bean to ensure it behaves like a prototype.
Create a factory method that returns a new instance of the prototype bean each time it is called.

Preparing for VMWare 2V0-72.22 Professional Develop VMware Spring? Now land the interview.

73% of qualified candidates get rejected because of weak resumes. Build an ATS-optimized, recruiter-ready resume in under 5 minutes - free to start.

Build My Resume Free