Scope of Spring Bean

Scope of Spring Bean





The scope of Spring's Bean includes the following:

  • (1) singleton: Singleton mode, a BeanFactory has and only one instance.
  • (2) prototype: Prototype mode, every time a Bean is obtained from the BeanFactory, a new instance will be created. (Multiple examples, principle clone copies of prototypes)
  • (3) request: A new bean is created for each request request, and this scope is only valid in the case of a web-based Spring ApplicationContext.
  • (4) session: Each session request will create a new bean, and this scope is only valid in the case of web-based Spring ApplicationContext.
  • (5) application: All sessions share a bean, and this scope is only valid in the case of web-based Spring ApplicationContext.
    When writing code, you usually use the ApplicationContext container to enjoy more functions and convenience.






My Github address , welcome everyone to join my open source project, or (contact me on my homepage) to join your open source project, click Github-Stars.

\ open source project name dependent type version number describe
1 spring-boot-starter-trie pom 1.0.0-SNAPSHOT The query speed under specific requirements far exceeds that of open source search tools, and the B+ tree under innodb or the inverted index in ES cannot compare with it.
2 spring-boot-starter-trie jar 1.0.0-M1 Provides SpringCloud-based service nodes, which can be used for service discovery through the Nacos registry, realizing dynamic expansion and contraction of the tree, and dynamic online and offline services.
3 Data-Provider pom 1.0.0-SNAPSHOT It provides queries from multiple data sources and data type synchronization. As a Jar, it can rely on dynamically providing data on other services.

Guess you like

Origin blog.csdn.net/jj89929665/article/details/130884250