1、创建一个maven项目
2、添加依赖pom.xml
<parent> <artifactId>spring-boot-starter-parent</artifactId> <groupId>org.springframework.boot</groupId> <version>2.7.1</version> </parent> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> </dependencies>
3、编写主程序启动类
package com.hbgc; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication public class AssetsManagerApplication { public static void main(String[] args) { SpringApplication.run(AssetsManagerApplication.class,args); } }
4、创建用于web访问的请求处理控制类
package com.hbgc.controller; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; @RestController public class HelloController { @GetMapping("/hello") public String hello() { return "Hello! Spring BooT"; } }