1、File------>New------>Project
2、spring Initializr------>选择JDK版本------->Next
3、填写包名称----->项目名称--------->Next
4、选择web项目------>Next
5、更改项目保存路径
6、第5步完成即可创建项目成功,删除如下图不必要的文件。
7、编写相关的Controller、Service
package com.rf.springboot.controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class HelloWorld {
@RequestMapping("/hello")
public String hello(){
return "hello world !";
}
}
8、启动主程序
9、访问localhost:8080/hello,如下图