1,添加依赖
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.7.1</version>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
2,启动项
@SpringBootApplication
public class springBootFirstApplication {
public static void main(String[] args) {
SpringApplication.run(springBootFirstApplication.class,args);
}
}
3,控制器
@RestController
public class controller {
@GetMapping("/first")
public String first() {
return "hello first springboot";
}
}
4,运行
在浏览器输入”localhost:8080/first“