kagkarlsson / db-scheduler

Persistent cluster-friendly scheduler for Java
Apache License 2.0
1.23k stars 188 forks source link

fix: 511 - Declare DbSchedulerAutoConfiguration#eagerDbSchedulerStarter as static #512

Closed NicklasWallgren closed 1 month ago

NicklasWallgren commented 2 months ago

The DbSchedulerAutoConfiguration#eagerDbSchedulerStarter must be declared as static to ensure it is available before the initialization of DbSchedulerAutoConfiguration. Spring Boot will otherwise try to instantiate the DbSchedulerAutoConfiguration class using a no-args constructor.

NOTE: Beans of this type will be instantiated very early in the spring application lifecycle so they should generally be declared static and not have any dependencies.

https://docs.spring.io/spring-boot/api/java/org/springframework/boot/LazyInitializationExcludeFilter.html#:~:text=NOTE%3A%20Beans%20of%20this%20type%20will%20be%20instantiated%20very%20early%20in%20the%20spring%20application%20lifecycle%20so%20they%20should%20generally%20be%20declared%20static%20and%20not%20have%20any%20dependencies.

Example - auto-configuration class with an args-constructor; https://github.com/spring-projects/spring-boot/blob/ef303e74f7b92373e32d1cf95a121b37d377960a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/jmx/JmxEndpointAutoConfiguration.java#L116

Fixes #511

Reminders


cc @kagkarlsson

kagkarlsson commented 1 month ago

Thank you for the quick fix @NicklasWallgren 👍

kagkarlsson commented 1 month ago

🎉 This issue has been resolved in v14.0.3 (Release Notes)