Skip to content

Conversation

adinauer
Copy link

@adinauer adinauer commented Aug 12, 2025

I tried duplicating the springBoot3 files to make opentelemetry-spring-boot-starter work with Spring Boot 4.

While I was able to deploy a modified version to my local Maven repository and confirm it fixes the ClassNotFoundException for org.springframework.boot.autoconfigure.web.client.RestClientAutoConfiguration, I was unable to make it coexist with Spring Boot 3 configuration.

IIRC Spring Boot 2 used spring.factories and support for org.springframework.boot.autoconfigure.AutoConfiguration.imports was added in Spring Boot 3, so it was fine for those to coexist. For Spring Boot 4 however, there'd have to be a mechanism of configuring whether to use imports from the Spring Boot 3 vs 4 sources. Event with having separate resources directories, I wasn't able to make this work since they still end up in the same JAR.

I might be wrong here^, if so, we can continue on this approach. If this holds true, I recommend duplicating the spring-boot-autoconfigure and spring-boot-starter modules for Spring Boot 4. I'll open another PR for this shortly. I opened this PR more for documenting what I tried, but recommend closing it in favor of #14416.

Attempt at fixing #14363

Copy link

linux-foundation-easycla bot commented Aug 12, 2025

CLA Not Signed

@github-actions github-actions bot added the test native This label can be applied to PRs to trigger them to run native tests label Aug 12, 2025
@otelbot-java-instrumentation
Copy link
Contributor

🔧 The result from spotlessApply was committed to the PR branch.

@laurit
Copy link
Contributor

laurit commented Aug 27, 2025

Since #14363 was resolved is this still relevant?

@laurit laurit added the needs author feedback Waiting for additional feedback from the author label Aug 27, 2025
@adinauer
Copy link
Author

My original suggestion was to close this PR in favor of #14416 but since you prefer implementing without the duplication, this PR might serve as a starting point, depending on how exactly support for Spring Boot 4 can be implemented. I'm not quite sure how to work around the shared org.springframework.boot.autoconfigure.AutoConfiguration.imports file for Spring Boot 3 and 4.

@github-actions github-actions bot removed the needs author feedback Waiting for additional feedback from the author label Aug 27, 2025
@laurit
Copy link
Contributor

laurit commented Aug 27, 2025

I'm not quite sure how to work around the shared org.springframework.boot.autoconfigure.AutoConfiguration.imports file for Spring Boot 3 and 4.

have you considered using the conditional annotations to ensure that configuration class is enabled only for boot 3 or 4? We already have a bunch of @ConditionalOnClass usages.

@adinauer
Copy link
Author

I can take another look after my vacation and see if that helps with org.springframework.boot.autoconfigure.AutoConfiguration.imports. Will be a while until then tho. Thanks for the suggestion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
test native This label can be applied to PRs to trigger them to run native tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants