Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/spring-projects/spring-boot/llms.txt

Use this file to discover all available pages before exploring further.

Spring Boot’s auto-configuration system is the engine behind convention-over-configuration: it inspects the libraries on your classpath, the beans already defined in your application context, and a set of environment properties, then automatically registers exactly the infrastructure beans your application needs — without requiring any explicit @Bean declarations from you. Understanding how this mechanism works lets you extend it, override it, and debug it when something does not behave as expected.

How auto-configuration works

Auto-configuration classes are regular @Configuration classes annotated with @AutoConfiguration. Spring Boot discovers them at startup by reading every META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports file found on the classpath. Each line in that file is a fully-qualified class name of an auto-configuration class to consider.
META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
org.springframework.boot.jdbc.autoconfigure.DataSourceAutoConfiguration
org.springframework.boot.jdbc.autoconfigure.JdbcTemplateAutoConfiguration
org.springframework.boot.hibernate.autoconfigure.HibernateJpaAutoConfiguration
To see which auto-configurations are active (or inactive, and why), start your application with --debug or -Ddebug=true. The conditions report printed to the log shows every auto-configuration class, which conditions passed, and which conditions caused it to be skipped. In an Actuator application, you can also query the /actuator/conditions endpoint at runtime.

The @AutoConfiguration annotation

@AutoConfiguration is a composed annotation that combines @Configuration(proxyBeanMethods = false) with auto-configuration-specific metadata. Disabling CGLIB proxying is the default because auto-configuration classes are typically infrastructure configuration that does not need full proxy semantics.
@AutoConfiguration(after = DataSourceAutoConfiguration.class)
@ConditionalOnClass({ DataSource.class, JdbcTemplate.class })
@ConditionalOnSingleCandidate(DataSource.class)
public class JdbcTemplateAutoConfiguration {

    @Bean
    @ConditionalOnMissingBean(JdbcOperations.class)
    JdbcTemplate jdbcTemplate(DataSource dataSource, JdbcProperties properties) {
        // ...
    }
}

Ordering auto-configurations

Auto-configurations can declare ordering constraints to ensure that one configuration runs before or after another:
  • @AutoConfiguration(after = X.class) — equivalent to @AutoConfigureAfter. Ensures this class is processed after X.
  • @AutoConfiguration(before = X.class) — equivalent to @AutoConfigureBefore. Ensures this class is processed before X.
Ordering only determines the order in which Spring evaluates conditions, not the order in which beans are instantiated at runtime. For runtime ordering, use @DependsOn or @Order on the beans themselves.

Conditional annotations

Auto-configurations use conditional annotations to activate only when the right conditions are met. Stacking multiple @Conditional* annotations requires all conditions to pass.
AnnotationActivates when…
@ConditionalOnClassAll listed classes are on the classpath.
@ConditionalOnMissingClassNone of the listed classes are on the classpath.
@ConditionalOnBeanA bean of the given type or name already exists.
@ConditionalOnMissingBeanNo bean of the given type or name exists (lets users override).
@ConditionalOnPropertyA configuration property has a specific value.
@ConditionalOnResourceA specific resource is present on the classpath.
@ConditionalOnWebApplicationThe application is a web application.
@ConditionalOnNotWebApplicationThe application is not a web application.
@ConditionalOnSingleCandidateExactly one candidate bean of the given type exists.
@ConditionalOnExpressionA SpEL expression evaluates to true.
@ConditionalOnMissingBean is the standard pattern auto-configurations use to back off when you provide your own bean. Define your own @Bean of the same type to take full control and disable the auto-configured one.

Disabling specific auto-configurations

You can exclude auto-configurations you do not want:
@SpringBootApplication(exclude = { DataSourceAutoConfiguration.class })
public class MyApplication { }

Auto-configuration classes by category

The classes below are read from the META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports files in the Spring Boot source. Only selected, commonly used classes are listed here; run --debug to see the complete list for your application.
These auto-configurations are always considered regardless of which starters are on the classpath.
ClassPurpose
org.springframework.boot.autoconfigure.context.ConfigurationPropertiesAutoConfigurationEnables @ConfigurationProperties bean processing.
org.springframework.boot.autoconfigure.context.MessageSourceAutoConfigurationAuto-configures MessageSource for internationalization.
org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfigurationRegisters a PropertySourcesPlaceholderConfigurer for ${…} resolution.
org.springframework.boot.autoconfigure.task.TaskExecutionAutoConfigurationConfigures an AsyncTaskExecutor for @Async and virtual threads.
org.springframework.boot.autoconfigure.task.TaskSchedulingAutoConfigurationConfigures a ThreadPoolTaskScheduler for @Scheduled.
org.springframework.boot.autoconfigure.aop.AopAutoConfigurationEnables Spring AOP via @EnableAspectJAutoProxy.
org.springframework.boot.autoconfigure.ssl.SslAutoConfigurationRegisters SSL bundles from spring.ssl.bundle.* properties.
Web auto-configurations set up the dispatcher, error handling, HTTP encoding, and view technologies.
ClassPurpose
org.springframework.boot.webmvc.autoconfigure.DispatcherServletAutoConfigurationRegisters DispatcherServlet for Spring MVC.
org.springframework.boot.webmvc.autoconfigure.WebMvcAutoConfigurationConfigures Spring MVC defaults (content negotiation, formatters, static resources).
org.springframework.boot.webmvc.autoconfigure.error.ErrorMvcAutoConfigurationProvides the default /error endpoint and BasicErrorController.
org.springframework.boot.servlet.autoconfigure.HttpEncodingAutoConfigurationSets the character encoding for HTTP requests and responses.
org.springframework.boot.servlet.autoconfigure.MultipartAutoConfigurationConfigures multipart file upload support.
org.springframework.boot.webflux.autoconfigure.WebFluxAutoConfigurationConfigures Spring WebFlux for reactive web applications.
org.springframework.boot.webflux.autoconfigure.error.ErrorWebFluxAutoConfigurationProvides reactive error handling via DefaultErrorWebExceptionHandler.
org.springframework.boot.thymeleaf.autoconfigure.ThymeleafAutoConfigurationConfigures Thymeleaf template engine and view resolver.
org.springframework.boot.freemarker.autoconfigure.FreeMarkerAutoConfigurationConfigures FreeMarker template engine.
org.springframework.boot.restclient.autoconfigure.RestClientAutoConfigurationConfigures RestClient.Builder with default settings.
org.springframework.boot.restclient.autoconfigure.RestTemplateAutoConfigurationConfigures RestTemplateBuilder for RestTemplate creation.
org.springframework.boot.webclient.autoconfigure.WebClientAutoConfigurationConfigures WebClient.Builder for reactive HTTP clients.
org.springframework.boot.graphql.autoconfigure.GraphQlAutoConfigurationConfigures Spring for GraphQL schema and execution.
org.springframework.boot.graphql.autoconfigure.servlet.GraphQlWebMvcAutoConfigurationExposes GraphQL over HTTP in servlet applications.
Data auto-configurations cover relational and NoSQL databases, connection pooling, and Spring Data repositories.
ClassPurpose
org.springframework.boot.jdbc.autoconfigure.DataSourceAutoConfigurationConfigures a DataSource (defaults to HikariCP).
org.springframework.boot.jdbc.autoconfigure.JdbcTemplateAutoConfigurationConfigures JdbcTemplate and NamedParameterJdbcTemplate.
org.springframework.boot.jdbc.autoconfigure.JdbcClientAutoConfigurationConfigures the fluent JdbcClient API.
org.springframework.boot.jdbc.autoconfigure.DataSourceTransactionManagerAutoConfigurationConfigures DataSourceTransactionManager for JDBC.
org.springframework.boot.hibernate.autoconfigure.HibernateJpaAutoConfigurationConfigures Hibernate as the JPA provider.
org.springframework.boot.data.jpa.autoconfigure.DataJpaRepositoriesAutoConfigurationEnables @EnableJpaRepositories for Spring Data JPA.
org.springframework.boot.data.jdbc.autoconfigure.DataJdbcRepositoriesAutoConfigurationEnables Spring Data JDBC repositories.
org.springframework.boot.mongodb.autoconfigure.MongoAutoConfigurationConfigures a MongoDB MongoClient.
org.springframework.boot.data.mongodb.autoconfigure.DataMongoAutoConfigurationConfigures MongoDB template and repositories.
org.springframework.boot.data.redis.autoconfigure.DataRedisAutoConfigurationConfigures RedisTemplate and StringRedisTemplate.
org.springframework.boot.flyway.autoconfigure.FlywayAutoConfigurationConfigures Flyway database migration.
org.springframework.boot.liquibase.autoconfigure.LiquibaseAutoConfigurationConfigures Liquibase database migration.
org.springframework.boot.r2dbc.autoconfigure.R2dbcAutoConfigurationConfigures a reactive R2DBC ConnectionFactory.
org.springframework.boot.data.elasticsearch.autoconfigure.DataElasticsearchAutoConfigurationConfigures Elasticsearch client and template.
org.springframework.boot.data.neo4j.autoconfigure.DataNeo4jAutoConfigurationConfigures Neo4j driver and template.
org.springframework.boot.jooq.autoconfigure.JooqAutoConfigurationConfigures jOOQ DSLContext.
Security auto-configurations set up Spring Security’s filter chain, user details, OAuth2, and SAML2.
ClassPurpose
org.springframework.boot.security.autoconfigure.SecurityAutoConfigurationRegisters the default SpringBootWebSecurityConfiguration and AuthenticationEventPublisher.
org.springframework.boot.security.autoconfigure.UserDetailsServiceAutoConfigurationConfigures an in-memory UserDetailsService with a generated password (for development).
org.springframework.boot.security.autoconfigure.web.servlet.ServletWebSecurityAutoConfigurationEnables @EnableWebSecurity in servlet applications.
org.springframework.boot.security.autoconfigure.web.reactive.ReactiveWebSecurityAutoConfigurationEnables @EnableWebFluxSecurity in reactive applications.
org.springframework.boot.security.oauth2.client.autoconfigure.OAuth2ClientAutoConfigurationConfigures OAuth2 / OpenID Connect client support.
org.springframework.boot.security.oauth2.server.resource.autoconfigure.OAuth2ResourceServerAutoConfigurationConfigures JWT or opaque-token resource server validation.
org.springframework.boot.security.oauth2.server.authorization.autoconfigure.servlet.OAuth2AuthorizationServerAutoConfigurationConfigures Spring Authorization Server.
org.springframework.boot.security.saml2.autoconfigure.Saml2RelyingPartyAutoConfigurationConfigures SAML 2.0 relying party (service provider).
Messaging auto-configurations support AMQP (RabbitMQ), Kafka, JMS, Pulsar, and other messaging systems.
ClassPurpose
org.springframework.boot.amqp.autoconfigure.RabbitAutoConfigurationConfigures RabbitMQ ConnectionFactory, RabbitTemplate, and listener containers.
org.springframework.boot.kafka.autoconfigure.KafkaAutoConfigurationConfigures Kafka KafkaTemplate, producer, consumer, and admin.
org.springframework.boot.jms.autoconfigure.JmsAutoConfigurationConfigures JMS JmsTemplate and listener container factory.
org.springframework.boot.activemq.autoconfigure.ActiveMQAutoConfigurationConfigures ActiveMQ Classic connection factory.
org.springframework.boot.artemis.autoconfigure.ArtemisAutoConfigurationConfigures ActiveMQ Artemis connection factory.
org.springframework.boot.pulsar.autoconfigure.PulsarAutoConfigurationConfigures Apache Pulsar client, producer, and consumer.
org.springframework.boot.rsocket.autoconfigure.RSocketServerAutoConfigurationConfigures an RSocket server.
org.springframework.boot.integration.autoconfigure.IntegrationAutoConfigurationConfigures Spring Integration message infrastructure.
Actuator auto-configurations expose production-ready endpoints. Observability auto-configurations integrate Micrometer metrics, tracing, and OpenTelemetry.
ClassPurpose
org.springframework.boot.actuate.autoconfigure.endpoint.EndpointAutoConfigurationCore endpoint infrastructure (discovery, caching, security).
org.springframework.boot.actuate.autoconfigure.endpoint.web.WebEndpointAutoConfigurationExposes endpoints over HTTP.
org.springframework.boot.health.autoconfigure.actuate.endpoint.HealthEndpointAutoConfigurationConfigures the /actuator/health endpoint.
org.springframework.boot.health.autoconfigure.application.DiskSpaceHealthContributorAutoConfigurationAdds a disk-space health indicator.
org.springframework.boot.actuate.autoconfigure.env.EnvironmentEndpointAutoConfigurationConfigures the /actuator/env endpoint.
org.springframework.boot.actuate.autoconfigure.logging.LoggersEndpointAutoConfigurationConfigures the /actuator/loggers endpoint for runtime log-level changes.
org.springframework.boot.actuate.autoconfigure.beans.BeansEndpointAutoConfigurationConfigures the /actuator/beans endpoint.
org.springframework.boot.micrometer.metrics.autoconfigure.MetricsAutoConfigurationConfigures the Micrometer MeterRegistry.
org.springframework.boot.micrometer.metrics.autoconfigure.export.prometheus.PrometheusMetricsExportAutoConfigurationExposes metrics in Prometheus format via /actuator/prometheus.
org.springframework.boot.micrometer.observation.autoconfigure.ObservationAutoConfigurationConfigures Micrometer ObservationRegistry for unified observability.
org.springframework.boot.micrometer.tracing.autoconfigure.MicrometerTracingAutoConfigurationIntegrates distributed tracing with Micrometer Tracing.
org.springframework.boot.micrometer.tracing.brave.autoconfigure.BraveAutoConfigurationConfigures Brave as the Micrometer Tracing implementation.
org.springframework.boot.opentelemetry.autoconfigure.OpenTelemetrySdkAutoConfigurationConfigures the OpenTelemetry SDK.
ClassPurpose
org.springframework.boot.cache.autoconfigure.CacheAutoConfigurationConfigures Spring’s CacheManager (auto-detects Caffeine, Redis, EhCache, etc.).
org.springframework.boot.autoconfigure.task.TaskExecutionAutoConfigurationConfigures the application TaskExecutor used for @Async and virtual threads.
org.springframework.boot.autoconfigure.task.TaskSchedulingAutoConfigurationConfigures ThreadPoolTaskScheduler for @Scheduled methods.
org.springframework.boot.quartz.autoconfigure.QuartzAutoConfigurationConfigures the Quartz Scheduler with JDBC or in-memory job stores.
org.springframework.boot.batch.autoconfigure.BatchAutoConfigurationConfigures Spring Batch infrastructure (job repository, launcher).

Writing your own auto-configuration

To package reusable auto-configuration as a library, create an @AutoConfiguration class and register it in your JAR’s META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports file:
@AutoConfiguration(after = DataSourceAutoConfiguration.class)
@ConditionalOnClass(MyService.class)
@EnableConfigurationProperties(MyProperties.class)
public class MyServiceAutoConfiguration {

    @Bean
    @ConditionalOnMissingBean
    MyService myService(MyProperties properties) {
        return new MyService(properties.getEndpoint());
    }
}
META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
com.example.mylib.autoconfigure.MyServiceAutoConfiguration

Build docs developers (and LLMs) love