如何學(xué)習(xí)Spring Boot

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. 嘗試

  1. 配置你項(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>

  1. 創(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);
    }
}

  1. Just Run,執(zhí)行Application.main() 或者 mvn:spring-boot:run
    啟動(dòng)成功后,訪問(wèn)http://localhost:8080/
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容