Spring Boot 是所有基于 Spring 开发的项目的起点。Spring Boot 的设计是为了让你尽可能快的跑起来 Spring 应用程序并且尽可能减少你的配置文件。简单来说就是SpringBoot其实不是什么新的框架,它默认配置了很多框架的使用方式,就像maven整合了所有的jar包,spring boot整合了所有的框架
Spring Boot makes it easy to create stand-alone, production-grade Spring based Applications that you can “just run”.
We take an opinionated view of the Spring platform and third-party libraries so you can get started with minimum fuss. Most Spring Boot applications need minimal Spring configuration.
这里就是官方对springboot的说明,翻译过来就是Spring Boot 可以轻松创建可以“直接运行”的独立的、生产级的基于 Spring 的应用程序。springboot对 Spring 平台和第三方库持固执己见的看法,因此您可以轻松上手。大多数 Spring Boot 应用程序需要最少的 Spring 配置。
先创建一个干净的maven项目

在pom.xml中引入springboot的父项目
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.5.3</version>
</parent>
在pom.xml中引入依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
springboot其实就是基于spring的,spring和springmvc中的用法在springboot中基本没变,我们来创建一个Controller来进行测试
@RestController
public class TestController {
@RequestMapping("/t1")
public String t1(){
return "success";
}
}
@SpringBootApplication
public class App {
public static void main(String[] args) {
SpringApplication.run(App.class);
}
}
注意:springboot中,默认扫描路径是启动类所在的包以及它的子包,我们使用@SpringBootApplication来标识启动类,在main方法中启动,具体细节后面说明。我的项目结构如下

我们启动运行 自己创建的启动类,控制台输出如下

然后我们来访问一下前面创建的Controller,端口默认是8080,访问地址就是http://localhost:8080/t1,访问该网页,显示如下,访问成功

到此,springboot的基本使用就说明完成了,springboot的其它用法以及细节说明在后面文件进行讲解