Spring Boot 3: spring.factories
About
In Spring Boot 3, the traditional META-INF/spring.factories mechanism was replaced by a new metadata-based system using:
META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports(for auto-configuration)META-INF/spring/org.springframework.bootfolder with structured metadata files for other use cases

Why the Change ?
Modularity: Split metadata per feature rather than one bulky file
Better performance: Optimized classpath scanning
Clarity: Easier to understand and manage for different framework extension points
Native image compatibility: Improves behavior in GraalVM and AOT (Ahead-of-Time) contexts
Replacing EnableAutoConfiguration
EnableAutoConfigurationOld Way (Spring Boot 2):
New Way (Spring Boot 3):
Create the file:
Add your class:
Java Class:
This is now the standard way to register auto-configuration classes in Spring Boot 3.
ApplicationContextInitializer, EnvironmentPostProcessor, RunListener
These are not moved to a new system. They still use spring.factories, even in Spring Boot 3.
So, for the following types, we still use META-INF/spring.factories:
Still supported in Spring Boot 3 via spring.factories:
spring.factories:ApplicationContextInitializer
Modify application context before refresh
EnvironmentPostProcessor
Add/override environment properties
ApplicationListener
Hook into Spring event lifecycle
SpringApplicationRunListener
Listen to Spring Boot startup phases
Example:
Comparison
Auto Configuration
spring.factories with EnableAutoConfiguration key
AutoConfiguration.imports file
Initializers
spring.factories
still spring.factories
Listeners
spring.factories
still spring.factories
Env Post Processor
spring.factories
still spring.factories
Lifecycle Hooks
spring.factories
still spring.factories
Last updated