如何在Spring中管理对象池?

时间:2022-11-07 16:58:51

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中,所有对象都被默认地视为单例对象。如果单例被设置为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个实例?用弹簧可以吗?

1 个解决方案

#1


14  

Pooling can be applied to any POJO with spring.

池可以应用于任何带有spring的POJO。

See here for more information.

更多信息请参见这里。

#1


14  

Pooling can be applied to any POJO with spring.

池可以应用于任何带有spring的POJO。

See here for more information.

更多信息请参见这里。