Spring Boot
是用來簡化Spring
應用的初始化開發過程。java
建立獨立的應用(jar|war形式
);web
須要用到spring-boot-maven-plugin插件
spring
直接嵌入式Tomcat,Jetty,Undertow
等Web容器;json
提供固化的starter
依賴,簡化構建配置;瀏覽器
提供條件化自動裝配
Spring或者第三方組件springboot
提供運維(Production-Ready
)特性,如`指標信息(Metrics),健康檢查或者外部化配置;app
Spring Boot Admin(Spring Boot Web監控平臺
)運維
提倡無代碼生成,而且不須要XML配置;maven
Java運行環境: Spring5.0最低版本要求是Java8
。ide
模塊類庫管理Apache Maven:SpringBoot官方兼容Maven 3.2或者更高版本
。
裝配IDE(基礎開發環境):Idea
或者Eclipse
或者MyEclipse
。
POM
依賴。
<packaging>pom</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<lombok.version>1.16.8</lombok.version>
</properties>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.8.RELEASE</version>
<relativePath/>
</parent>
<dependencies>
<!--提供簡單註解簡化Java代碼開發-->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${spring-boot.version}</version>
<!--must configuration executable-->
<configuration>
<executable>true</executable>
</configuration>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
POM
依賴
<dependencies>
<!--spring boot web 依賴-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
啓動項目,spring-boot-starter-web默認嵌入式web容器時Tomcat,默認啓動端口是8080
。而且
spring-boot-starter-web模塊引入了spring-boot-starter-json
模塊,可使用Restful
風格API設計。
打開瀏覽器,訪問http://localhost:8080/hello 。效果不在演示。