filmov
tv
How Spring Boot Auto Configuration Works with Spring's @EnableAutoConfiguration Annotations

Показать описание
One of the most compelling features of Spring and Spring Boot is AutoConfiguration.
The Spring EnableAutoConfiguration annotation, and the various AutoConfig classes that support it, are what makes auto configuration in Spring Boot possible.
In this Spring Boot tutorial, autoconfiguration with the EnableAutoConfiguration annotation is explored.
We show you how Spring auto configuration works with and without Spring Boot. We show you how Spring allows autoconfigured resources to be autowired in as beans, and we show you how to achieve the same autoconfiguration results yourself.
We then explore all of the autoconfigurable types in Spring Boot, and then show you how to create a Spring Boot auto configuration class of your own.
If you want to be an expert at Spring Boot autoconfiguration and the Spring EnableAutoConfiguration annotation, this is the right Spring tutorial for you!
FROM THE SPRING JAVADOC:
When using @SpringBootApplication, the auto-configuration of the context is automatically enabled and adding this annotation has therefore no additional effect.
The package of the class that is annotated with @EnableAutoConfiguration, usually through @SpringBootApplication, has specific significance and is often used as a 'default'. For example, it will be used when scanning for @Entity classes. It is generally recommended that you place @EnableAutoConfiguration (if you're not using @SpringBootApplication) in a root package so that all sub-packages and classes can be searched.
Auto-configuration classes are regular Spring @Configuration beans. They are located using ImportCandidates. Generally auto-configuration beans are @Conditional beans (most often using @ConditionalOnClass and @ConditionalOnMissingBean annotations).
The Spring EnableAutoConfiguration annotation, and the various AutoConfig classes that support it, are what makes auto configuration in Spring Boot possible.
In this Spring Boot tutorial, autoconfiguration with the EnableAutoConfiguration annotation is explored.
We show you how Spring auto configuration works with and without Spring Boot. We show you how Spring allows autoconfigured resources to be autowired in as beans, and we show you how to achieve the same autoconfiguration results yourself.
We then explore all of the autoconfigurable types in Spring Boot, and then show you how to create a Spring Boot auto configuration class of your own.
If you want to be an expert at Spring Boot autoconfiguration and the Spring EnableAutoConfiguration annotation, this is the right Spring tutorial for you!
FROM THE SPRING JAVADOC:
When using @SpringBootApplication, the auto-configuration of the context is automatically enabled and adding this annotation has therefore no additional effect.
The package of the class that is annotated with @EnableAutoConfiguration, usually through @SpringBootApplication, has specific significance and is often used as a 'default'. For example, it will be used when scanning for @Entity classes. It is generally recommended that you place @EnableAutoConfiguration (if you're not using @SpringBootApplication) in a root package so that all sub-packages and classes can be searched.
Auto-configuration classes are regular Spring @Configuration beans. They are located using ImportCandidates. Generally auto-configuration beans are @Conditional beans (most often using @ConditionalOnClass and @ConditionalOnMissingBean annotations).
Комментарии