Support Spring Boot 4.0 bootstrap context package relocation#115
Support Spring Boot 4.0 bootstrap context package relocation#115
Conversation
|
Important Review skippedBot user detected. To trigger a single review, invoke the You can disable this status message by setting the Comment |
In Spring Boot 4.0, the bootstrap-related classes were moved from org.springframework.boot to org.springframework.boot.bootstrap. This change adds a BootstrapRegistryHelper utility class that uses reflection to support both package locations, ensuring compatibility with Spring Boot 2.x, 3.x, and 4.x. Co-authored-by: nobodyiam <837658+nobodyiam@users.noreply.github.com>
- Use more specific ReflectiveOperationException instead of generic Exception - Simplified static initializer by reusing bootstrap package variable Co-authored-by: nobodyiam <837658+nobodyiam@users.noreply.github.com>
|
There are further issues that need to be fixed. Exception in thread "main" java.lang.IllegalStateException: java.lang.NoSuchMethodError: 'org.springframework.boot.ConfigurableBootstrapContext org.springframework.boot.context.config.ConfigDataLoaderContext.getBootstrapContext()' |
…Spring Boot 4.0 Add reflection-based method to handle ConfigDataLoaderContext.getBootstrapContext() which also has a different return type in Spring Boot 4.0. This fixes the second NoSuchMethodError that occurs when loading config data. Co-authored-by: nobodyiam <837658+nobodyiam@users.noreply.github.com>
Fixed in commit 5f54fdf. Added reflection-based method |
|
@copilot This pr looks good to me. Please update the CHANGES.md. |
What's the purpose of this PR
Spring Boot 4.0 relocated bootstrap context classes from
org.springframework.boottoorg.springframework.boot.bootstrap. This causesNoSuchMethodErroron bothApplicationStartingEvent.getBootstrapContext()andConfigDataLoaderContext.getBootstrapContext()when usingapollo-client-config-datawith Spring Boot 4.0.This PR adds a reflection-based compatibility layer to support both Spring Boot 2.x/3.x and 4.x.
Which issue(s) this PR fixes:
Brief changelog
BootstrapRegistryHelperutility that detects Spring Boot version at runtime and uses reflection to invoke bootstrap context methods from either package locationApplicationStartingEvent.getBootstrapContext()andConfigDataLoaderContext.getBootstrapContext()via reflectionConfigurableBootstrapContextorBootstrapRegistry.InstanceSupplierto useObjecttype with helper methods:ApolloSpringApplicationRegisterListenerApolloConfigDataLoaderApolloConfigDataLoaderInitializerApolloClientExtensionInitializeFactoryApolloClientLongPollingExtensionInitializerApolloClientWebsocketExtensionInitializerApolloClientWebClientCustomizerFactoryFollow this checklist to help us incorporate your contribution quickly and easily:
mvn clean testto make sure this pull request doesn't break anything.CHANGESlog.Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.