I have a Spring boot application that has some external dependencies (e.g. files outside the project that must exist for the application to run correctly).
One of my beans has a method @PostConstructthat performs initialization. I would like to exit cleanly and gracefully if the initialization is not successful - for example, files were not found.
A call ((ConfigurableApplicationContext)applicationContext).close();in a method @PostConstructresults in
java.lang.IllegalStateException: LifecycleProcessor not initialized - call 'refresh' before invoking lifecycle methods via the context
and a chain of other Exceptions. Is there any way to do this right?
source
share