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. 第二個(gè)類級(jí)別(class-level)的注解是@EnableAutoConfiguration。這個(gè)注解告訴SpringBoot“猜測(cè)”您想怎樣基于您添加的jar包依賴配置Spring。 由于spring-boot-starter-web中添加了Tomcat和Spring MVC(的依賴), 所以自動(dòng)配置將假設(shè)您在開(kāi)發(fā)一個(gè)Web應(yīng)用程序,并相應(yīng)的設(shè)置Spring。

Starters and Auto-configuration
啟動(dòng)器(Starter)和自動(dòng)配置(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.
自動(dòng)配置設(shè)計(jì)用于和“啟動(dòng)器(Starter)”一起很好的工作,但這兩個(gè)概念沒(méi)有直接聯(lián)系。 您可以自由選擇啟動(dòng)器之外的jar依賴項(xiàng)。SpringBoot仍然盡力自動(dòng)配置您的應(yīng)用程序。

以上內(nèi)容是否對(duì)您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號(hào)
微信公眾號(hào)

編程獅公眾號(hào)