Last active
May 27, 2021 09:57
-
-
Save amirex128/55afa61b224a18f4eb12594191d278a9 to your computer and use it in GitHub Desktop.
its a cheat sheet for spring boot's annotation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Configuration classes is to be sources of bean definitions for the Spring IoC Container. | |
@Component is an annotation that allows Spring to automatically detect our custom beans. | |
// create new bean for your class | |
@Bean | |
// The scope of a bean defines the life cycle and visibility of that bean in the contexts we use it. | |
//we have this scope: | |
//singleton scoped beans are scoped to a single application context only. | |
//singleton @Scope("singleton") //create class once | |
//prototype @Scope("prototype ") //create class affter every request Autowire | |
//request @RequestScope | |
//session @SessionScope | |
//application scoped, the same instance of the bean is shared across multiple servlet-based applications running in the same ServletContext | |
//application @ApplicationScope | |
//websocket | |
// this look like the @Autowire with @Qualifier | |
@Resource("name of the Bean method") | |
@Value("${spring.application.name}") //get value from application properties and set on the your variable //with default value @Value("${property_key_name:default_value}") | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment