1.打开idea,创建项目
2.选择Spring Initializr,next
3.输入Artifact,Next
4.勾选web(一般情况也就够用了)
5.点击finish
6.项目结构(可以删除”.mvn、mvnw、mvnw.cmd”文件)
7.写一个Hello word程序
不用修改生成的pom.xml文
package com.example;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* @Author: yf
* @Date: 2017/11/17.
*/
@RestController
public class HelloController {
@RequestMapping("/hello")
public String hello() {
return "Hello, world!";
}
}
8.运行程序(默认使用jetty启动)
9.运行结果
在浏览器地址栏输入地址:http://localhost:8080/hello