Skip to content

Bug with AutoConfigure using spring.factories in SpringBoot 3 #33413

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

Closed
zromano opened this issue Nov 29, 2022 · 4 comments
Closed

Bug with AutoConfigure using spring.factories in SpringBoot 3 #33413

zromano opened this issue Nov 29, 2022 · 4 comments
Labels
status: invalid An issue that we don't feel is valid

Comments

@zromano
Copy link

zromano commented Nov 29, 2022

Hi team, I started looking into upgrading to SpringBoot 3 and I think I may have stumbled upon a bug.

We have a library that uses spring.factories to make Spring automatically recognize a configuration class in a library. After upgrading to SpringBoot 3, the application using the library will no longer recognize configuration class and use it to create beans.

To make things easier, I made two simple apps that repro the issue and show that it will autoconfigure and create a bean on SpringBoot 2.7.5 and it will not on SpringBoot 3. You can just run the SpringBootTest in either repo to see the issue.

Also worth noting, if you add @ComponentScan("com.lib") to DemoApplication.java in the SpringBoot 3.0.0 example it will work again, but we shouldn't need to add that since we have the spring.factories in the lib.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Nov 29, 2022
@knoobie
Copy link

knoobie commented Nov 29, 2022

You can find more about it in the migration guide of 2.7

@scottfrederick
Copy link
Contributor

Spring Boot 3.0 requires AutoConfiguration classes to be specified in a META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports instead of in spring.factories, as documented in the migration guide. The use of AutoConfiguration.imports was optional in Spring Boot 2.7 but is required in 3.0.

@scottfrederick scottfrederick closed this as not planned Won't fix, can't repro, duplicate, stale Nov 29, 2022
@scottfrederick scottfrederick added status: invalid An issue that we don't feel is valid and removed status: waiting-for-triage An issue we've not yet triaged labels Nov 29, 2022
@zromano
Copy link
Author

zromano commented Nov 29, 2022

Ah,I'm glad it's not a bug! Thank you both!!

That wasn't called out in the 3.0.0 release notes and I didn't think to look back at 2.7 notes. Hopefully this thread will help someone else if they have the same issue!

@scottfrederick
Copy link
Contributor

The 3.0 release notes link to the dedicated migration guide, which is where most of the information needed when migrating from 2.7 to 3.0 is located.

loicgreffier added a commit to michelin/kstreamplify that referenced this issue Jun 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: invalid An issue that we don't feel is valid
Projects
None yet
Development

No branches or pull requests

4 participants