In my Spring boot application, we utilize @RefreshScope for dynamic reloading of beans after configuration changes. It works, but I have encountered an issue when combining the @RefreshScope on beans with methods annotated @PostConstruct and @PreDestroy. It seems the @PostConstruct is not called after refresh.
When booting the app, the @PostConstruct method is called normally. When invoking refresh, the @PreDestroy method gets invoked normally as well, and I would expect @PostConstruct to be called on the new proxied bean instance, but it is not. There is important init/destroy-logic going on in these methods, so not having them called is a problem.
Anyone encountered the same problem, and is this a bug or a "feature"? Is there a way to make this work?
Best regards
/refreshor programmatically!? - Sigrist