SpringBoot Web项目依赖分析

SpringBoot Web项目依赖分析

在上篇中,我们得到如下的pom.xml

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">

4.0.0

org.springframework.boot

spring-boot-starter-parent

2.2.3.RELEASE

com.example

demo

0.0.1-SNAPSHOT

demo

Demo project for Spring Boot

1.8

org.springframework.boot

spring-boot-starter-web

org.springframework.boot

spring-boot-starter-test

test

org.springframework.boot

spring-boot-maven-plugin

看看其核心类容:

1.parent

org.springframework.boot

spring-boot-starter-parent

2.5.6

2.dependencies

org.springframework.boot

spring-boot-starter-web

org.springframework.boot

spring-boot-starter-test

test

按住ctrl并点击parent中spring-boot-stater-parent节点,可以看到

图片.png

spring-boot-stater-parent有一个parent spring-boot-dependencies

根据名字分析,是spring-boot项目依赖的

继续点击spring-boot-dependencies

可以看到其在properties中配置了大量的依赖版本

![图片.png](https://upload-images.jianshu.io/upload_images/15204427-d5adbee2905a628c.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

我当前这个版本(2.2.3.RELEASE)在properties中共配置了203个依赖的版本

properties下面 dependencyManagement节点中,配置了依赖组建的版本:

图片.png

在项目的pom.xml中查看依赖树:

图片.png

可以看到springboot-starter-web添加了tomcat,web,webmvc,spring-core,spring-context等依赖

这也就是为什么我们可以直接通过DemoApplication.main来运行,而不需要配置外部servlet容器的原因,同时,通过这个starter-web就已经将web相关的依赖都整合进来了。

springboot中提供了很多starter,比如

spring-boot-starter-web

spring-boot-starter-cache

spring-boot-starter-security

spring-boot-starter-jdbc-swagger

spring-boot-starter-data-xxx

以上spring-boot-starter-开头的都是官方支持的,这些依赖在导入的时候,无需指定版本,因为他们的版本已经在spring-boot-dependencies中指定了

还有一些第三方的:

例如mybatis-spring-boot-starter,这种以-spring-boot-starter结尾的,是第三方根据springboot的规范,实现了第三方框架与springboot的整合,引入依赖时需要指定版本,因为其版本管理不包含在spring-boot-dependencies中。

相关推荐

巨嗨| 99%的人都不知道KTV流行音乐中有一个不成文的潜规则!
微信无法安装?常见问题及解决方法详解
365体育网址

微信无法安装?常见问题及解决方法详解

📅 08-09 👁️ 323
作为国际超模,如果在T台上摔倒会怎么样?后果是什么?
投中2023年度中国最佳创业投资机构TOP100发布(附完整名单)
京东白条开通额度一般是多少 京东白条初始额度有多少?
将“沙漠
365体育网址

将“沙漠"翻译成英文

📅 11-16 👁️ 258
世界十大守门员 世界排名前十的守门员
365体育网址

世界十大守门员 世界排名前十的守门员

📅 08-03 👁️ 681
感冒症狀、多久會好、什麼時候需要看醫生?告訴你感冒的5個階段
在 iPhone 和 iPad 上使用低数据模式
3658188

在 iPhone 和 iPad 上使用低数据模式

📅 07-31 👁️ 8491