
上QQ阅读APP看本书,新人免费读10天
设备和账号都新为新人
1.3 体验Spring Boot
1.3.1 Spring Boot的应用结构
下面对1.2节中的应用做一下解析,应用的结构如图1-3所示。

图1-3
下面对build.gradle、QuickStartApplication和application.properties进行讲解。
1.3.2 build.gradle

a.Spring Boot Gradle插件,版本为2.1.6.RELEASE。
b.Java插件。
c.Spring的版本依赖管理插件。
d.jar包下载仓库,这里使用的是Maven中心库。
e.定义本应用的依赖。
1.3.3 QuickStartApplication
Spring Boot提供了一个颠覆传统企业级应用的开发方式,在这种类似于简单的控制台程序的开发运行方式中,只需提供一个简单的入口main方法,即可运行应用。

◎Spring Boot之所以神奇,主要源于@SpringBootApplication注解,本书将在第4章进行讲解,在这里只需保证代码不变即可。
◎@RestController声明了一个基于RESTful的Web控制器。
◎@GetMapping("/hello-world") 声明了一个应用的端点,访问地址为“http://ip:port/hello-world”,访问得到的返回结果是字符串“Hello World!!!”。
1.3.4 application.properties
application.properties提供了对Spring Boot的默认行进行定制的能力,Spring Boot支持“properties”格式和“yml”格式,如修改Web容器的端口号。
