when is a spring beans destroy-method called?
It may be too late for the OP, but if someone is still looking for it...
The close method is in AbstractApplicationContext
and not ApplicationContext
, also another way is to use ctx.registerShutdownHook()
instead of ctx.close()
for obvious reasons that while running Junit
s you might want to close the context but not while in production environment so let Spring decide on when to close it.