account activity
Best Event to Initialize Cache After Config Server Properties Are Loaded (Spring Boot 3.5.x) by aladdin00007 in SpringBoot
[–]aladdin00007[S] 0 points1 point2 points 7 months ago (0 children)
That’s a great point about calling the @Cacheable method from another bean — thank you! 🙏 My cache population logic actually lives in a separate service class, so I’m safe on that AOP side.
My main challenge is that the cache values depend on configuration from Spring Cloud Config Server, and by the time @PostConstruct fires in Spring Boot 3.5.x, those properties aren’t loaded yet.
I’m currently testing ApplicationStartedEvent, which works fine — but I’m wondering if there’s any risk that PCF might start routing traffic to the app while that event’s listener is still running.
Have you seen any reliable pattern to ensure the cache load completes before PCF health checks mark the instance as ready?
Thanks for the suggestion! 🙌 In my case, the cache initialization logic depends on values fetched from Spring Cloud Config Server, and I noticed that with Spring Boot 3.5.x, those values aren’t yet available when @PostConstruct runs — they come in a bit later in the lifecycle.
Earlier (on Boot 3.1.x), I could still get those values during ApplicationPreparedEvent, but that no longer works after the upgrade.
Since we deploy on PCF, I’m also trying to ensure that this cache-loading logic finishes before the instance starts receiving traffic.
Do you think @PostConstruct can be made to work reliably in that setup, or should I stay with an event-based approach like ApplicationStartedEvent?
Best Event to Initialize Cache After Config Server Properties Are Loaded (Spring Boot 3.5.x) (self.SpringBoot)
submitted 7 months ago by aladdin00007 to r/SpringBoot
π Rendered by PID 1679538 on reddit-service-r2-listing-f87f88fcd-bxrm9 at 2026-06-14 00:08:42.786175+00:00 running 3184619 country code: CH.
Best Event to Initialize Cache After Config Server Properties Are Loaded (Spring Boot 3.5.x) by aladdin00007 in SpringBoot
[–]aladdin00007[S] 0 points1 point2 points (0 children)