Embed presentation
Downloaded 71 times
![S P R I N G C O N T R O L F L O W
B E A N S C O P E S1
P O P U L A R A N N O T A T I O N S2
SPRING
CHEAT
SHEET
singleton, default scope
1 instance for whole application context, for
immutable objects
prototype , @Scope("prototype")
1 instance per request , for mutable objects
By constructor (Best option) , for required dependecties
By setter , for optional dependecties
By field, for optional dependecties
I N J E C T O F B E A N I N T O Y O U R C L A S S3
1 HTTP Request -> DispatcherServlet
[Filtering , Security, Compression]
2 DispatcherServlet -> @RestController
[Integration logic]
3 @RestController ->
@Service class OR @Bean class
[Application logic] ->
4 @Service class -> @Repository
[DataBase operations] ->
5 @Repository -> @Entity Class
[Business Logic] ->
6 @RestController ->
HTTP Response returned
MynameisMarkand
I'mJavaSenior
Consultantwith+10
yearsofexperience](https://image.slidesharecdn.com/springcs-180220210922/75/Spring-cheat-sheet-1-2048.jpg)

The document discusses Spring bean scopes and dependency injection. It explains that singleton beans have one instance for the entire application context while prototype beans have one instance per request. It recommends using constructor injection for required dependencies and setter or field injection for optional dependencies. It also provides an overview of how a typical HTTP request flows through a Spring application from the DispatcherServlet to controllers to services to repositories to entities and back to generate a response.
![S P R I N G C O N T R O L F L O W
B E A N S C O P E S1
P O P U L A R A N N O T A T I O N S2
SPRING
CHEAT
SHEET
singleton, default scope
1 instance for whole application context, for
immutable objects
prototype , @Scope("prototype")
1 instance per request , for mutable objects
By constructor (Best option) , for required dependecties
By setter , for optional dependecties
By field, for optional dependecties
I N J E C T O F B E A N I N T O Y O U R C L A S S3
1 HTTP Request -> DispatcherServlet
[Filtering , Security, Compression]
2 DispatcherServlet -> @RestController
[Integration logic]
3 @RestController ->
@Service class OR @Bean class
[Application logic] ->
4 @Service class -> @Repository
[DataBase operations] ->
5 @Repository -> @Entity Class
[Business Logic] ->
6 @RestController ->
HTTP Response returned
MynameisMarkand
I'mJavaSenior
Consultantwith+10
yearsofexperience](https://image.slidesharecdn.com/springcs-180220210922/75/Spring-cheat-sheet-1-2048.jpg)