谁能解释这两个 Spring bean 范围之间的区别?
我熟悉单例模式。
这会是唯一的区别吗?
您可以使用应用程序范围在 Spring 容器中拥有一个 bean 列表。
另外,您是否能够在一个 Spring 容器中运行多个 Web 服务器?如果是,那将是在单例范围上使用应用程序范围的原因,否则 bean 将在两个服务器上共享。
最佳答案
This is somewhat similar to a Spring singleton bean but differs in two important ways: It is a singleton per ServletContext, not per Spring 'ApplicationContext' (or which there may be several in any given web application), and it is actually exposed and therefore visible as a ServletContext attribute
关于spring - Java Spring bean 范围 : singleton vs application,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33571259/