第一步:使用IDEA创建一个springboot工程,File->New->Project
创建项目
第二步:选择Spring Initializr设置项目参数, 勾选spring web
项目参数
勾选spring web
生产的项目结构如下:
项目结构
第四步:新建HelloController.java
package com.example.firstlearn.controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping
public class HelloController {
@RequestMapping("/hello")
public String hello() {
return "hello world";
}
}第五步:运行FirstLearnApplication.java中的main方法启动项目,浏览器输入http://localhost:8080/hello
| 留言与评论(共有 0 条评论) “” |