Update 36.2. Locating auto-configuration candidates.md

master
qibaoguang 2015-02-27 21:30:08 +08:00
parent 99516241dd
commit a0e8a047c9
1 changed files with 9 additions and 0 deletions

View File

@ -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后面。