简体   繁体   English

Spring Boot 使用的默认 bean 范围是什么?

[英]What is the default bean scope used by Spring Boot?

I can't find this information anywhere.我在任何地方都找不到这些信息。 Can someone explain how spring boot 'decides' what the right scope is?有人可以解释一下 spring boot 如何“决定”正确的范围是什么? Are the beans all singletons?豆子都是单身吗?

Spring Boot doesn't decide anything about the bean scope, this is plain Spring framework functionality. Spring Boot 不决定关于 bean 范围的任何事情,这是普通的 Spring 框架功能。 Default bean scope is singleton scope (meaning, one instance of that bean in the application).默认 bean 范围是单例范围(意思是应用程序中该 bean 的一个实例)。

Here is the official documentation:以下是官方文档:

https://docs.spring.io/spring-framework/docs/current/spring-framework-reference/core.html#beans-factory-scopes https://docs.spring.io/spring-framework/docs/current/spring-framework-reference/core.html#beans-factory-scopes

Default scope for a Spring Bean in singleton.单例中 Spring Bean 的默认范围。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM