11.3.2 @EnableAutoConfiguration注解

2018-08-14 15:05 更新

The second class-level annotation is @EnableAutoConfiguration. This annotation tells Spring Boot to “guess” how you want to configure Spring, based on the jar dependencies that you have added. Since spring-boot-starter-web added Tomcat and Spring MVC, the auto-configuration assumes that you are developing a web application and sets up Spring accordingly. 第二个类级别(class-level)的注解是@EnableAutoConfiguration。这个注解告诉SpringBoot“猜测”您想怎样基于您添加的jar包依赖配置Spring。 由于spring-boot-starter-web中添加了Tomcat和Spring MVC(的依赖), 所以自动配置将假设您在开发一个Web应用程序,并相应的设置Spring。

Starters and Auto-configuration
启动器(Starter)和自动配置(Auto-configuration)

Auto-configuration is designed to work well with “Starters”, but the two concepts are not directly tied. You are free to pick and choose jar dependencies outside of the starters. Spring Boot still does its best to auto-configure your application.
自动配置设计用于和“启动器(Starter)”一起很好的工作,但这两个概念没有直接联系。 您可以自由选择启动器之外的jar依赖项。SpringBoot仍然尽力自动配置您的应用程序。

以上内容是否对您有帮助:
在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号