1.Spring Boot可以輕松創(chuàng)建單獨(dú)的,基于生產(chǎn)級(jí)的Spring應(yīng)用程序,您需要做的可能“僅僅是去運(yùn)行”。 我們提供了Spring Platform對(duì)Spring 框架和第三方庫(kù)進(jìn)行處理,盡可能的降低使用的復(fù)雜度。大多數(shù)情況下Spring Boot應(yīng)用只需要非常少的配置。
2.Spring boot的特點(diǎn)
Create stand-alone Spring applications
Embed Tomcat, Jetty or Undertow directly (no need to deploy WAR files)
快速構(gòu)建獨(dú)立的Spring Application,使用內(nèi)嵌容器,無(wú)需部署到外部容器,你要做的僅僅是運(yùn)行她。
Provide opinionated 'starter' POMs to simplify your Maven configuration
Automatically configure Spring whenever possible
提供眾多擴(kuò)展的‘starter’,通過(guò)依賴(lài)探知自動(dòng)配置,你要做的僅僅是添加Maven依賴(lài)。
Provide production-ready features such as metrics, health checks and externalized configuration
提供生產(chǎn)環(huán)境下的性能健康狀態(tài)監(jiān)控及外部化配置,讓你時(shí)刻掌控她。
Absolutely no code generation and no requirement for XML configuration
無(wú)需生成代碼及XML配置,一切從簡(jiǎn)。
3. 嘗試
- 配置你項(xiàng)目的pom.xml
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.1.RELEASE</version>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
- 創(chuàng)建Application.java
@RestController
@EnableAutoConfiguration
public class Application {
@RequestMapping("/")
String index() {
return "Welcome to know Spring Boot !";
}
public static void main(String[] args) throws Exception {
SpringApplication.run(Application.class, args);
}
}
- Just Run,執(zhí)行
Application.main()或者 mvn:spring-boot:run
啟動(dòng)成功后,訪問(wèn)http://localhost:8080/