1. 원하는 class에 Spring Application Context를 auto-configuration 합니다.
(사용자가 원하는 bean을 추측하여 configure)
2. configure 되길 원하지 않는 클래스를 manually exclude 할 수 있습니다.
3. @EnableAutoConfiguration를 사용한 클래스의 패키지는 sub-package에 있는
@Entity 클래스들을 scan합니다. (따라서 root package의 classdㅔ서 사용하길 권장)
//===================================원문===================================//
org.springframework.boot.autoconfigure
Annotation Type EnableAutoConfiguration
@Target(value=TYPE) @Retention(value=RUNTIME) @Documented @Inherited @AutoConfigurationPackage @Import(value=EnableAutoConfigurationImportSelector.class) public @interface EnableAutoConfiguration
Enable auto-configuration of the Spring Application Context, attempting to guess and configure beans that you are likely to need. Auto-configuration classes are usually applied based on your classpath and what beans you have defined. For example, If you havetomcat-embedded.jar
on your classpath you are likely to want aTomcatEmbeddedServletContainerFactory
(unless you have defined your ownEmbeddedServletContainerFactory
bean).Auto-configuration tries to be as intelligent as possible and will back-away as you define more of your own configuration. You can always manuallyexclude()
any configuration that you never want to apply (useexcludeName()
if you don't have access to them). You can also exclude them via thespring.autoconfigure.exclude
property. Auto-configuration is always applied after user-defined beans have been registered.
The package of the class that is annotated with@EnableAutoConfiguration
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
in a root package so that all sub-packages and classes can be searched.
Auto-configuration classes are regular SpringConfiguration
beans. They are located using theSpringFactoriesLoader
mechanism (keyed against this class). Generally auto-configuration beans are@Conditional
beans (most often using@ConditionalOnClass
and@ConditionalOnMissingBean
annotations).- Author:
- Phillip Webb, Stephane Nicoll
- link:
- http://docs.spring.io/spring-boot/docs/current/api/org/springframework/boot/autoconfigure/EnableAutoConfiguration.html
댓글 없음:
댓글 쓰기