新建springboot项目
作者:互联网
1.新建项目,选择Spring Initializr
2.直接finish,然后就等待下载各种包,大约10分钟左右
3.包变绿后,pom.xml中导入web依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>2.5.6</version>
</dependency>
4.新建controller包,新建HelloController类
5.HelloController类
package com.kuang.controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class HelloController {
@RequestMapping("/hello")
public String hello() {
return "Hello World";
}
}
6.运行,访问8080,一个接口就成功了
标签:web,RestController,springboot,项目,新建,springframework,HelloController,org 来源: https://blog.csdn.net/www1411050101/article/details/121527711