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

Spring cheat sheet

  • 1.
    S P RI 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