開發(fā)環(huán)境:
- jdk版本:jdk8
- maven版本:maven-3.5.2
- 開發(fā)工具:itellij idea 2017.1
前提條件:已安裝以上軟件并配置好jdk和maven的環(huán)境變量
創(chuàng)建步驟:
點擊坐上角file ---》選擇new ---》點擊project... 如下圖所示:
點擊左邊spring initializr ---》 右上角新建jdk(若有則不需要) ---》 點擊next 如下圖所示:
看需求修改下圖中的信息后點擊next(可以直接使用默認)
點擊左邊的web ---》 選中中間列的web ---》 點擊next 如下圖所示:
輸入項目名稱和保存路徑 --- 》點擊finish
創(chuàng)建的項目如下圖所示:
創(chuàng)建hellocontroller類,代碼如下所示:
1
2
3
4
5
6
7
8
9
10
11
|
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 頁面如下所示:
總結(jié)
以上所述是小編給大家介紹的intellij idea創(chuàng)建spring-boot項目的圖文教程,希望對大家有所幫助,如果大家有任何疑問歡迎給我留言,小編會及時回復(fù)大家的!
原文鏈接:https://www.cnblogs.com/guohaien/p/8317962.html