https://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/context/support/AbstractApplicationContext.html#start-- 官方文档
http://stackoverflow.com/questions/24145070/use-of-start-method-in-classpathxmlapplicationcontext 其他网站搜索得到的
简单copy过来,只是为了记录一下。正确与否不知道。。
Spring provides a ApplicationListener
interface to listen for various ApplicationEvent
s. One such event is the ContextStartedEvent
. You can create a bean of some class that implements ApplicationListener<ContextStartedEvent>
.
When you invoke start()
, the ApplicationContext
will publish such an event and allApplicationListener
beans registered for ContextStartedEvent
(they get registered automatically if found in the context) will get notified.
If you don't call start()
, they will not get notified.