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.

  • https://github.com/zromano/SpringBoot-3.0.0-With-AutoConfig
  • https://github.com/zromano/SpringBoot-2.7.5-With-AutoConfig

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.

Comment From: knoobie

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

Comment From: scottfrederick

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.

Comment From: zromano

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!

Comment From: scottfrederick

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.