Spring bean destroy-method , singleton and prototype scopes

后端 未结 6 1363
暗喜
暗喜 2020-12-31 00:34

I am new to the spring framework, started with some tutorials to learn it.

I have following files,

# MainProgram.java

package test.spring;
im         


        
6条回答
  •  孤城傲影
    2020-12-31 00:51

    xmlDestroy() method is called with singleton scope bean but not with prototype because

    Spring does not manage the complete lifecycle of a prototype bean: the container instantiates, configures, decorates and otherwise assembles a prototype object, hands it to the client and then has no further knowledge of that prototype instance. For releasing resources try to implement a custom bean post processor.

    Unlike singleton beans where the spring container manages the complete life-cycle

    You can have a look at this basic tutorial for differences between different contexts

    Refer documentation

提交回复
热议问题