SpringBoot基础系列文章
SpringBoot基础(一):快速入门
简单、快速地创建一个独立的、生产级别的Spring应用(说明:SpringBoot底层是Spring)少量配置即可快速整合Spring平台以及第三方技术SpringBoot特性
总结:简化整合、配置、开发、部署
pom.xml
spring-boot-starter-parentspring-boot-starter-web包含了web开发的所有依赖 4.0.0 org.springframework.boot spring-boot-starter-parent 2.7.11 springboot 8 8 UTF-8 org.springframework.boot spring-boot-starter-web org.springframework.boot spring-boot-maven-plugin 核心启动类
// 这是一个SpringBoot应用 @SpringBootApplication public class SpringBootMainApplication { public static void main(String[] args) { SpringApplication.run(SpringBootMainApplication.class,args); } } Controller测试类
@RestController public class HelloController { @GetMapping("/hello") public String hello(){ return "Hello,Spring Boot !"; } } 访问路径:http://localhost:8080/hello

之前传统框架对依赖版本的选择具有固定的搭配格式,并且这些依赖版本的选择还不能乱搭配。于是SpringBoot将所有的技术版本的常见使用方案(parent版本)都整理出来,以后开发者直接使用它提供的方案(parent版本)即可,就不用担心冲突问题了。
parent版本即为SpringBoot项目pom文件的父工程坐标
版本号版本管理,不会导入坐标 org.springframework.boot spring-boot-starter-parent 2.7.11
spring-boot-starter-parent坐标内容
spring-boot-dependencies依赖管理,下面讲java编译版本以及编码方式打包插件的版本,这也是SpringBoot的pom文件中打包插件不用写版本号的原因
依赖管理标签内,则表示只是引入申明,只有在子pom中使用(不用写版本号) 依赖才会导入
导入依赖则需要在SpringBoot的pom文件中配置,如导入activemq org.apache.activemq activemq-amqp 修改版本号,可以在SpringBoot的pom文件中配置 5.7.0 # 或者直接修改版本,maven就近原则 org.apache.activemq activemq-amqp 5.7.0 starter定义了使用某种技术时对于依赖的固定搭配格式,可以帮助开发者减少依赖配置spring-boot-starter-**-spring-boot-starterspring-boot-starter-web的依赖 org.springframework.boot spring-boot-starter-web 具体依赖的坐标
spring-boot-starter-json和spring-boot-starter-tomcat的内容

spring-boot-autoconfigure的jar包
Spring容器对象(IoC容器)包及其子包@SpringBootApplication public class SpringBootMainApplication { public static void main(String[] args) { //获取ioc容器 ConfigurableApplicationContext context = SpringApplication.run(SpringBootMainApplication.class, args); //获取组件 User user = context.getBean(User.class); System.out.println(user); } } spring-boot-starter-tomcat说起 org.springframework.boot spring-boot-starter-tomcat 2.7.11 compile 
从上面说到的spring-boot-autoconfigure的jar包里的配置类,找到ServletWebServerFactoryAutoConfigurationServletWeb服务器工厂自动配置。
Tomcat类来自于tomcat-embed-core-9.0.74.jar,由于导入这个jar,才能创建Tomcat容器工厂类,后续才能创建Tomcat容器并启动。

创建Tomcat

启动Tomcat

挂起Tomcat,这也就是启动类main函数不会执行结束的原因
