Quick revision
The short answer
AutoConfiguration.imports is a plain text file at META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports inside a jar, listing one fully qualified auto-configuration class name per line. Up to Boot 2.6, auto-configurations were registered in META-INF/spring.factories under the EnableAutoConfiguration key; Boot 2.7 introduced the imports file and Boot 3.0 removed the spring.factories registration for auto-configurations. Classes listed there should carry @AutoConfiguration and must not be picked up by component scanning, while spring.factories itself remains in use for other extension points such as FailureAnalyzer and ApplicationListener.
What to remember
In this answer, we saw that AutoConfiguration.imports is a one-class-per-line file under META-INF/spring that Boot reads from every jar to find auto-configuration candidates. It replaced the EnableAutoConfiguration key in spring.factories in Boot 2.7, which Boot 3 stopped reading, listed classes should use @AutoConfiguration and stay out of component scanning, and spring.factories remains the place for other extension points like FailureAnalyzer and ApplicationListener.
Your turn
Answer it aloud as you would in the interview, or type your answer below. Then show one part at a time and compare.
AutoConfiguration.imports is a plain text file at META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports inside a jar, listing one fully qualified auto-configuration class name per line. Up to Boot 2.6, auto-configurations were registered in META-INF/spring.factories under the EnableAutoConfiguration key; Boot 2.7 introduced the imports file and Boot 3.0 removed the spring.factories registration for auto-configurations. Classes listed there should carry @AutoConfiguration and must not be picked up by component scanning, while spring.factories itself remains in use for other extension points such as FailureAnalyzer and ApplicationListener.
Background to this question
Anyone who writes a starter or a shared library for Spring Boot needs to know this file, because it is the only way Boot finds auto-configuration outside the application. It is also a frequent cause of trouble during upgrades, because a library written for Boot 2 can compile and load perfectly on Boot 3 while its auto-configuration is silently ignored. In this answer, we will see what the file looks like and where it goes, how it replaced the older spring.factories entry and why, how the listed classes should be written, and what spring.factories is still used for.
1What the File Looks Like and Where It Goes
The file lives in the resources of the library, so it ends up inside the jar at a fixed path. Its name is the fully qualified name of the @AutoConfiguration annotation followed by .imports. Each line is the full class name of one auto-configuration; blank lines are ignored and lines starting with # are comments.
At startup, Boot's AutoConfigurationImportSelector asks ImportCandidates to load this file from every jar on the classpath and joins the lists. Those are the candidates; conditions on each class then decide which of them actually contribute beans.
2What It Replaced: the spring.factories Entry
Until Boot 2.6, auto-configurations were registered in META-INF/spring.factories, a properties file used by Spring's SpringFactoriesLoader for many kinds of extension. The auto-configuration key was the full name of @EnableAutoConfiguration, and the value was a comma-separated list, usually spread over many lines with backslashes.
| Boot version | spring.factories key | AutoConfiguration.imports |
|---|---|---|
| 2.6 and earlier | read | not supported |
| 2.7 | read, deprecated | read |
| 3.x | ignored for auto-configuration | read (the only way) |
| 4.x | ignored for auto-configuration | read (the only way) |
Boot 2.7 introduced the imports file and still read both, so libraries had time to move. Boot 3.0 removed support for the spring.factories key for auto-configurations. On Boot 3 or 4, an entry like the one above is simply never read, and no error is raised.
The reasons for the change were practical. One file mixing many unrelated extension types was hard to read and merge, a dedicated file per purpose is simpler, and the one-name-per-line format is easier to generate and to process in tools such as ahead-of-time compilation for native images.
3How the Listed Classes Should Be Written
A class listed in the imports file should be annotated with @AutoConfiguration, which Boot 2.7 also introduced. It is a specialised @Configuration with proxyBeanMethods set to false, and it carries before, after, beforeName and afterName attributes for ordering relative to other auto-configurations.
The class must not be found by component scanning. If it were, it would be registered as an ordinary configuration class together with the application's own configuration, so its ordering would be ignored and conditions such as @ConditionalOnMissingBean and @ConditionalOnBean would be evaluated before Boot's auto-configurations, giving wrong answers. Putting auto-configurations in a package no application scans is the safe rule. @SpringBootApplication's scan has an AutoConfigurationExcludeFilter that skips listed auto-configurations, but an application using its own @ComponentScan does not get that filter.
4What spring.factories Is Still Used For
spring.factories did not disappear. It still registers many extension points that Boot loads through SpringFactoriesLoader, and libraries keep using it for those. Common examples are FailureAnalyzer, which turns a startup exception into a readable message; ApplicationListener and ApplicationContextInitializer, which hook into the start of the application; EnvironmentPostProcessor, which adjusts the environment before the context is created; and AutoConfigurationImportFilter, which is how Boot's own early filters are registered.
Some of these interfaces moved packages in Boot 4, for example EnvironmentPostProcessor, so the key must match the interface name of your Boot version; check your version. The rule of thumb is simple: auto-configurations go in the imports file, everything else that Boot loads through factories stays in spring.factories.
5Follow-up questions
Can a library support Boot 2.7 and Boot 3 at the same time?
Yes. It can ship both the imports file and the old spring.factories entry. Boot 2.7 reads both, though it avoids registering a class twice, and Boot 3 reads only the imports file. Once Boot 2 support ends, the spring.factories entry can be removed.
Is there a similar file for test auto-configurations?
Yes. Test slices such as @DataJpaTest use their own imports files under META-INF/spring, named after the slice's annotation, for example one for AutoConfigureDataJpa, which lists the auto-configurations that slice includes.
How do you check which candidates Boot found?
The condition evaluation report, printed with debug=true, lists every candidate it evaluated under positive or negative matches. A class that appears in neither section was never a candidate, which usually means it is missing from the imports file.
6Conclusion
In this answer, we saw that AutoConfiguration.imports is a one-class-per-line file under META-INF/spring that Boot reads from every jar to find auto-configuration candidates. It replaced the EnableAutoConfiguration key in spring.factories in Boot 2.7, which Boot 3 stopped reading, listed classes should use @AutoConfiguration and stay out of component scanning, and spring.factories remains the place for other extension points like FailureAnalyzer and ApplicationListener.
Open with
AutoConfiguration.imports is the file a library uses to tell Spring Boot about its auto-configurations. Its path is META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports, inside the jar, and it contains one fully qualified class name per line, with hash comments allowed.
Then, if they want more
At startup Boot's import selector loads this file from every jar on the classpath, and those classes become the candidates whose conditions are evaluated. Before Boot 2.7, the same list lived in META-INF/spring.factories under the EnableAutoConfiguration key as a comma-separated value.
Boot 2.7 introduced the imports file and read both, and Boot 3.0 removed support for the spring.factories key, so on Boot 3 an old entry is silently ignored. The listed classes should be annotated with @AutoConfiguration, which is a configuration class with proxyBeanMethods false and before and after attributes for ordering.
They must not be picked up by component scanning, because then they would be processed with the application's own configuration, ignoring the ordering and evaluating bean conditions too early, so I keep them in a package that no application scans. spring.factories is still used for other extension points, such as FailureAnalyzer, ApplicationListener, ApplicationContextInitializer and EnvironmentPostProcessor.
So the rule is: auto-configurations go in the imports file, everything else stays in spring.factories.
About this answer
- Last updated
- 12 November 2026
- Checked
- Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
- Where the question comes from
- Written by Scrivio for practice. It is not taken from an interview.
- Official documentation
- Spring Boot reference
Report an issue with this answer
Copy the line below and send it to the author with what you found. It carries the address of this page.
Issue with "What is the AutoConfiguration.imports file, where is it located, and what replaced it...": https://scrivio-interview-library.netlify.app/spring-boot/auto-configuration/b52388366e/