codecamp

11.3.2 @EnableAutoConfiguration注解

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仍然尽力自动配置您的应用程序。

11.3 编写实例代码
11.4 运行实例程序
温馨提示
下载编程狮App,免费阅读超1000+编程语言教程
取消
确定
目录

I. SpringBoot文档

1.关于文档

2.获得帮助

3.初始学习步骤

4.工作中使用SpringBoot

5.学习Spring Boot新特性

6.投入生产

7.深入学习

II. 入门指南

8. Spring Boot介绍

9. 系统必要条件

9.1. 支持的Servlet容器

10. Spring Boot安装

10.1. 安装说明(开发人员)

10.1.1 Maven安装

10.1.2 Gradle Installation (空)

10.2. Installing the Spring Boot CLI (空)

10.3. Upgrading from an Earlier Version of Spring Boot (空)

11. 开发第一个Spring Boot应用程序

11.1 创建POM

11.2 添加 Classpath 依赖

11.3 编写实例代码

11.3.1 @RestController和@RequestMapping注解

11.3.2 @EnableAutoConfiguration注解

11.3.3 “main”方法

11.4 运行实例程序

11.5 创建可执行程序(Executable Jar)

12. 接下来阅读什么

III. 使用Spring Boot (空)

13. Build Systems(空)

13.2 Maven(空)

13.2.2 Using Spring Boot without the Parent POM(空)

13.5 Starters(空)

IV. Spring Boot新特性 (空)

V. Actuator执行器 (空)

VI. 部署Spring Boot Applications (空)

VII. Spring Boot CLI (空)

VIII. 构建工具插件(空)

68. Spring Boot Maven Plugin(空)

IX. ‘How-to’guides(空)

X. 附录 (空)

关闭

MIP.setData({ 'pageTheme' : getCookie('pageTheme') || {'day':true, 'night':false}, 'pageFontSize' : getCookie('pageFontSize') || 20 }); MIP.watch('pageTheme', function(newValue){ setCookie('pageTheme', JSON.stringify(newValue)) }); MIP.watch('pageFontSize', function(newValue){ setCookie('pageFontSize', newValue) }); function setCookie(name, value){ var days = 1; var exp = new Date(); exp.setTime(exp.getTime() + days*24*60*60*1000); document.cookie = name + '=' + value + ';expires=' + exp.toUTCString(); } function getCookie(name){ var reg = new RegExp('(^| )' + name + '=([^;]*)(;|$)'); return document.cookie.match(reg) ? JSON.parse(document.cookie.match(reg)[2]) : null; }