Spring: How to cleanly terminate prototype-scoped beans?

前端 未结 2 686
鱼传尺愫
鱼传尺愫 2021-01-04 07:35

According to Spring documentation when a bean is scoped as \"prototype\" spring does not manage the complete lifecycle of its objects. More specifically the destruction life

2条回答
  •  温柔的废话
    2021-01-04 07:54

    The only clean way to terminate prototype-scoped bean is to explicitly call some of its "destroy"-methods to dispose resources. You can also use Phantom References. Here is more info on different types of references.

提交回复
热议问题