Intellij Idea新建spring boot工程

1.打开Intellij Idea,新建工程,选择Create Nex Project。

2.选择Spring Initializr,Next

3.可选择默认,也可修改Group,Artifact。Next

4.默认选Spring Boot 2.0.1。勾选Web->Web

5.勾选Template Engines->Thymeleaf,Next

6.修改Project name和Project location,Finish。

7.工程修建完成后,在DemoApplication.java所在目录中,新建一个Controller包,在Controller包中,新建TestCtrl.java

package com.liujy.demo.controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class TestCtrl {
@RequestMapping(value = "/test")
@ResponseBody
public String test() {
return "Hello, world!";
}
}
8.修改端口号8080

9.启动程序,在DemoApplication右键,选Debug 'DemoApplication'


10.在浏览器中输入地址http://localhost:8080/test


posted @ 2018-05-02 16:29  微风吹过jy  阅读(107)  评论(0)    收藏  举报