Migrating Spring Boot Starters: From spring.factories to AutoConfiguration.imports
This guide explains why Spring Boot deprecates the META-INF/spring.factories file, how the change affects custom starters, and provides step‑by‑step code examples for migrating to the new AutoConfiguration.imports mechanism.
If you are a Spring Boot user, you know that adding a feature is as easy as adding the corresponding starter dependency in Maven or Gradle, without writing XML or Java configuration classes.
Behind the scenes, Spring Boot does not eliminate the beans you would normally configure; it provides default configuration classes and uses the /META-INF/spring.factories file to list them. When the application starts, Spring Boot reads this file from each starter and loads the specified configuration classes.
Starting with Spring Boot 2.7, the /META-INF/spring.factories file is deprecated and will be removed in Spring Boot 3. Custom starter developers must migrate to the new mechanism.
For example, a Swagger starter previously had the following /META-INF/spring.factories content:
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
com.spring4all.swagger.SwaggerAutoConfigurationTo migrate, create a new file
/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.importsand place the fully‑qualified configuration class name inside:
com.spring4all.swagger.SwaggerAutoConfigurationNote that the new file resides under an additional spring directory.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Programmer DD
A tinkering programmer and author of "Spring Cloud Microservices in Action"
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
