溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

Intellij IDEA如何創(chuàng)建spring-boot項目

發(fā)布時間:2021-06-07 11:22:53 來源:億速云 閱讀:194 作者:小新 欄目:編程語言

這篇文章將為大家詳細講解有關Intellij IDEA如何創(chuàng)建spring-boot項目,小編覺得挺實用的,因此分享給大家做個參考,希望大家閱讀完這篇文章后可以有所收獲。

開發(fā)環(huán)境:

  • jdk版本:JDK8 

  • maven版本:maven-3.5.2  

  • 開發(fā)工具:Itellij IDEA 2017.1

前提條件:已安裝以上軟件并配置好jdk和maven的環(huán)境變量

創(chuàng)建步驟:

點擊坐上角file ---》選擇new ---》點擊project... 如下圖所示:

Intellij IDEA如何創(chuàng)建spring-boot項目

點擊左邊Spring Initializr ---》 右上角新建jdk(若有則不需要) ---》 點擊next 如下圖所示:

Intellij IDEA如何創(chuàng)建spring-boot項目

看需求修改下圖中的信息后點擊next(可以直接使用默認)

Intellij IDEA如何創(chuàng)建spring-boot項目

點擊左邊的Web ---》 選中中間列的Web ---》 點擊next 如下圖所示:

Intellij IDEA如何創(chuàng)建spring-boot項目

輸入項目名稱和保存路徑 --- 》點擊finish

Intellij IDEA如何創(chuàng)建spring-boot項目

創(chuàng)建的項目如下圖所示:

Intellij IDEA如何創(chuàng)建spring-boot項目

創(chuàng)建HelloController類,代碼如下所示:

package com.example.demo.controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/hello")
public class HelloController {
 @RequestMapping("/say")
 public String sayHello() {
  return "hello world";
 }
}

執(zhí)行DemoApplication中main方法后訪問http://localhost:8080/hello/say 頁面如下所示:

Intellij IDEA如何創(chuàng)建spring-boot項目

關于“Intellij IDEA如何創(chuàng)建spring-boot項目”這篇文章就分享到這里了,希望以上內容可以對大家有一定的幫助,使各位可以學到更多知識,如果覺得文章不錯,請把它分享出去讓更多的人看到。

向AI問一下細節(jié)

免責聲明:本站發(fā)布的內容(圖片、視頻和文字)以原創(chuàng)、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI