本周我将开启Springboot的案例学习
pom.xml
首先需要在pom.xml文件中添加父工程和web开发的起步依赖
<!--springboot需要继承的父工程-->
<parent>
<artifactId>spring-boot-starter-parent</artifactId>
<groupId>org.springframework.boot</groupId>
<version>2.1.8.RELEASE</version>
</parent>
<dependencies>
<!--web开发的起步依赖-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
HelloController.class
@RestController
public class HelloController {
@RequestMapping("/hello")
public String hello(){
return "hello Spring Boot !";
}
}
HelloApplication.class
创建引导类作为springboot项目的入口
@SpringBootApplication
public class HelloApplication {
public static void main(String[] args) {
SpringApplication.run(HelloApplication.class,args);
}
}
本文介绍了如何使用SpringBoot进行项目初始化,包括在pom.xml中添加父工程依赖和web开发起步依赖,以及创建HelloController和HelloApplication的基本步骤。
1375

被折叠的 条评论
为什么被折叠?



