Spring Core · interview question
Which bean scope would you use in a Spring application to ensure a new bean instance is created for each HTTP request?
Multiple choiceMediumchapter-9-curatedpremiumspring-coreapplication-properties
Answer and explanation
Correct answer
D. Request
Why
The 'Request' scope is used to create a new bean instance for each HTTP request. This is particularly useful in web applications where you need separate instances for each client interaction.
Test yourself on Spring Core
A free test with instant, explained results. No account needed.
More Spring Core questions
- In a Spring Boot application, what happens if a method annotated with @Transactional calls a private method also…
- Which layer should coordinate inventory checks, payment, and order persistence for a checkout request?
- What role do Entities typically play in a Spring Boot application?
- How can you externalize configuration in a Spring Boot application?
- Which issue might arise from using field injection in Spring Boot, particularly when managing dependencies?
- In a Spring Boot application, what is the main purpose of the @ComponentScan annotation?