java listen to ContextRefreshedEvent

后端 未结 3 834
我寻月下人不归
我寻月下人不归 2021-02-04 09:30

I have a classX in my spring application in which I want to be able to find out if all spring beans have been initialized. To do this, I am trying to listen ContextRefreshedEven

3条回答
  •  长情又很酷
    2021-02-04 10:18

    I will prefer ApplicationReadyEvent. I found ContextRefreshedEvent is called before my http server is started. ApplicationReadyEvent will make sure your application is ready to take request.

        @EventListener(ApplicationReadyEvent.class)
        public void startApp() {
            LOGGER.info("Application is now ready!");
        }
    

提交回复
热议问题