java 如何在 Spring 中管理对象池?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/893041/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How does one manage object pooling in Spring?
提问by Cuga
It's my understanding that in Spring, all objects are treated by default as singletons. If singleton is set to false, then a new object will be served at each request.
我的理解是,在 Spring 中,默认情况下所有对象都被视为单例。如果 singleton 设置为 false,则每个请求都会提供一个新对象。
But what if I wanted to pool objects? Say set a range from a min of 1 to a max of 10 instances? Is this possible using Spring?
但是如果我想池化对象呢?假设设置从最小 1 到最大 10 个实例的范围?这可以使用 Spring 吗?

