When is ContextRefreshedEvent fired in Spring?

前端 未结 1 1076
臣服心动
臣服心动 2021-01-07 23:25

I know that it is fired once when the ApplicationContext is fully loaded, but what about after that during runtime? The word \"Refreshed\" implies that it will be triggered

相关标签:
1条回答
  • 2021-01-08 00:17

    it is fired when properties, xml or any schema files are loaded/refreshed, http://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/context/support/AbstractApplicationContext.html#refresh--

    Load or refresh the persistent representation of the configuration, which might an XML file, properties file, or relational database schema.

    It is fired implicitly by spring usually, but you should be able to fire that on certain instances, But here is java doc says when that happens

    As this is a startup method, it should destroy already created singletons if it fails, to avoid dangling resources. In other words, after invocation of that method, either all or no singletons at all should be instantiated.

    0 讨论(0)
提交回复
热议问题