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.

Programmer DD
Programmer DD
Programmer DD
Migrating Spring Boot Starters: From spring.factories to AutoConfiguration.imports

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.SwaggerAutoConfiguration

To migrate, create a new file

/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports

and place the fully‑qualified configuration class name inside:

com.spring4all.swagger.SwaggerAutoConfiguration

Note that the new file resides under an additional spring directory.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

JavaBackend DevelopmentSpring BootautoconfigurationStarter
Programmer DD
Written by

Programmer DD

A tinkering programmer and author of "Spring Cloud Microservices in Action"

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.