diff --git a/IV. Spring Boot features/36.2. Locating auto-configuration candidates.md b/IV. Spring Boot features/36.2. Locating auto-configuration candidates.md index e69de29..de9f16f 100644 --- a/IV. Spring Boot features/36.2. Locating auto-configuration candidates.md +++ b/IV. Spring Boot features/36.2. Locating auto-configuration candidates.md @@ -0,0 +1,9 @@ +### 36.2. 定位auto-configuration候选者 + +Spring Boot会检查你发布的jar中是否存在META-INF/spring.factories文件。该文件应该列出以EnableAutoConfiguration为key的配置类: +```java +org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ +com.mycorp.libx.autoconfigure.LibXAutoConfiguration,\ +com.mycorp.libx.autoconfigure.LibXWebAutoConfiguration +``` +如果配置需要应用特定的顺序,你可以使用[@AutoConfigureAfter](http://github.com/spring-projects/spring-boot/tree/master/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/AutoConfigureAfter.java)或[@AutoConfigureBefore](http://github.com/spring-projects/spring-boot/tree/master/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/AutoConfigureBefore.java)注解。例如,你想提供web-specific配置,你的类就需要应用在WebMvcAutoConfiguration后面。