Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Conversation

NicklasWallgren
Copy link
Contributor

@NicklasWallgren NicklasWallgren commented Jul 8, 2024

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

  • Added/ran automated tests
  • Update README and/or examples
  • Ran mvn spotless:apply

cc @kagkarlsson

@NicklasWallgren NicklasWallgren changed the title #511 - Declare DbSchedulerAutoConfiguration#eagerDbSchedulerStarter as static fix #511 - Declare DbSchedulerAutoConfiguration#eagerDbSchedulerStarter as static Jul 8, 2024
@NicklasWallgren NicklasWallgren changed the title fix #511 - Declare DbSchedulerAutoConfiguration#eagerDbSchedulerStarter as static fix: 511 - Declare DbSchedulerAutoConfiguration#eagerDbSchedulerStarter as static Jul 8, 2024
@kagkarlsson
Copy link
Owner

Thank you for the quick fix @NicklasWallgren 👍

@kagkarlsson kagkarlsson merged commit e11e04e into kagkarlsson:master Jul 23, 2024
9 of 14 checks passed
@kagkarlsson kagkarlsson added the released Issue has been released label Jul 23, 2024
@kagkarlsson
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
released Issue has been released
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Spring Context not loading with lazy-init from version 14.0.1
2 participants