SpringBoot入门
快速搭建Spring环境,是Spring的顶级项目之一,只是提供了快速Spring 项目的方式,并没有在功能上进行增强
快速构建
SpringBoot在运行后会运行自带的TomCat,实现网页的基本构建
<!-- springboot工程需要继承的父工程 -->
<parent>
<artifactId>spring-boot-starter-parent</artifactId>
<groupId>org.springframework.boot</groupId>
<version>3.0.2</version>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
HelloController.java
@RestController
public class HelloController {
@RequestMapping("/hello")
public String hello(){
return "hello springboot";
}
}
HelloApplication.java
// 引导类,SpringBoot项目入口
@SpringBootApplication
public class HelloApplication {
public static void main(String[] args) {
SpringApplication.run(HelloApplication.class,args);
}
}
PS!!! 通过IDEA可以快速构建Springboot的相关配置文件。