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