依赖管理
<parent>
<groupId>org.springframework.bootgroupId>
<artifactId>spring-boot-starter-parentartifactId>
<version>2.7.3version>
parent>
他的父项目
<parent>
<groupId>org.springframework.bootgroupId>
<artifactId>spring-boot-dependenciesartifactId>
<version>2.7.3version>
parent>
几乎声明了所有开发中常用的依赖的版本号,自动版本仲裁机制
1、spring-boot-starter-*:*就是某种场景
2、只要引入starter,这个场景的所有常规需要的依赖我们都会自动注入
3、springboot所有支持的场景
https://docs.spring.io/spring-boot/docs/current/reference/html/using.html#using.build-systems.starters
4、*-spring-boot-starter:是第三方提供的简化开发的场景启动器
5、所有场景启动器最底层的依赖
<dependency>
<groupId>org.springframework.bootgroupId>
<artifactId>spring-boot-starterartifactId>
<version>2.7.3.RELEASEversion>
<scope>compilescope>
dependency>
1、引入依赖默认都可以不写版本号
2、引入非版本仲裁jar,需要写版本号
1、查看spring-boot-dependencies里面规定当前依赖的版本
2、也可以在当前项目里重写配置修改版本号,如:
<properties>
<mysql.version>8.0.30mysql.version>
properties>
(1)引入Tomcat依赖
(2)配置Tomcat
<dependency>
<groupId>org.springframework.bootgroupId>
<artifactId>spring-boot-starter-tomcatartifactId>
<version>2.7.3version>
<scope>compilescope>
dependency>
(1)引入SpringMVC全套组件
(2)自动配好SpringMVC常用组件
<dependency>
<groupId>org.springframeworkgroupId>
<artifactId>spring-webmvcartifactId>
<version>5.3.22version>
<scope>compilescope>
dependency>
帮助我们配置好了所有web开发的常见场景
(1)主程序所在包及其下面所有子包里面的组件都会被默认扫描进来
(2)这样的话就这种结构下就不需要以前的包扫描配置
(3)想要改变扫描路径的话,可以使用 @SpringBootApplication(scanBasePackages = “com.work”),或者使用之前我们在Spring里学的@ComponentScan来指定扫描路径
@SpringBootApplication
等同于
@SpringBootConfiguration
@EnableAutoConfiguration
@ComponentScan("com.work.boot")
(1)默认配置最终都会映射到某个类上
(2)配置文件的值最终会绑定某个类,这个类会在容器中创建对象
(1)根据自己的需要,加入各种starter
(2)自己引入了哪些场景,这些场景的自动配置才会开启
(3)SpringBoot所有的自动配置功能都在 spring-boot-autoconfigure 包里面