Appearance
Maven 常见问题处理
1. pom.xml 文件
1.1. “提供可传递的易受攻击的依赖项” 警告
spring-boot-starter-thymeleaf 依赖项上提示警告 提供可传递的易受攻击的依赖项 maven:org.yaml:snakeyaml:1.30(Provides transitive vulnerable dependency maven:org.yaml:snakeyaml:1.30),简单来说就是项目中引用了一个被认为是有漏洞的依赖项。
XML
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>1
2
3
4
2
3
4
有以下处理方案:
升级依赖项
打开 Maven 中央仓库,搜索提示有漏洞的依赖项,上述示例中为
snakeyaml:
图 1.1 - snakeyaml 可以看到目前没有漏洞且在用的主流版本为 2.0,所以我们选择将项目中所有依赖的
snakeyaml都切换至 2.0 版本。XML<dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-thymeleaf</artifactId> </dependency> ... </dependencies> <dependencyManagement> <dependencies> <dependency> <groupId>org.yaml</groupId> <artifactId>snakeyaml</artifactId> <version>2.0</version> </dependency> </dependencies> </dependencyManagement>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17移除依赖项
如果这个库不是必须的,则我们可以考虑从项目中移除它:
XML<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-thymeleaf</artifactId> <exclusions> <exclusion> <groupId>org.yaml</groupId> <artifactId>snakeyaml</artifactId> </exclusion> </exclusions> </dependency>1
2
3
4
5
6
7
8
9
10忽略警告(不推荐);