使用最新版(2020)IntelliJ IDEA 新建 Spring Boot 2.0 项目
生活随笔
收集整理的這篇文章主要介紹了
使用最新版(2020)IntelliJ IDEA 新建 Spring Boot 2.0 项目
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
使用最新版(2020)IntelliJ IDEA 新建 Spring Boot 2.0 項目
一:創(chuàng)建項目,并添加相應依賴
-
新建Project,并指定Project為Spring Initializr類型。
-
注:默認鏡像url為:https://start.soring.io
-
由于本人JDK 為9.0版本,就選擇Java Version 8.0,因為項目JDK版本必須要小于或等于Java JDK 環(huán)境版本。
-
只需要勾選Web下的Spring Web 依賴即可;需要實現(xiàn)更多功能,可自行勾選相應的功能依賴。
-
繼續(xù)點擊Next,即可完成項目創(chuàng)建。
二:編寫相應的測試類:
-
Spring Boot 項目中不需要像JavaWeb項目,配置Tomcat環(huán)境,自身攜帶;
-
項目架構:如下圖所示
-
在helloWorld包下,新建HelloWorldTest類;
package com.example.test.helloworld;import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;@RestController
public class HelloWorldTest {@RequestMapping("/helloWorld")public String hellWorld(){return "Hello World!";}
}
三:點擊HelloworldApplication,編譯并運行;
四:在瀏覽器中輸入:http://localhost:8080/helloWorld
總結:Spring Boot 所需環(huán)境:
- 安裝JDK
- IntelliJ IDEA
- Apache Maven
總結
以上是生活随笔為你收集整理的使用最新版(2020)IntelliJ IDEA 新建 Spring Boot 2.0 项目的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Git 基本指令
- 下一篇: 基于Android和SpringBoot