spring_reference/II. Getting started/11.3.2. The @EnableAutoConf...

6 lines
636 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

### 11.3.2. @EnableAutoConfiguration注解
第二个类级别的注解是`@EnableAutoConfiguration`。这个注解告诉Spring Boot根据添加的jar依赖猜测你想如何配置Spring。由于`spring-boot-starter-web`添加了Tomcat和Spring MVC所以auto-configuration将假定你正在开发一个web应用并相应地对Spring进行设置。
**Starter POMs和Auto-Configuration**设计auto-configuration的目的是更好的使用"Starter POMs"但这两个概念没有直接的联系。你可以自由地挑选starter POMs以外的jar依赖并且Spring Boot将仍旧尽最大努力去自动配置你的应用。