1.分析单个jar包被那些父包依赖:
mvn dependency:tree -Dverbose -Dincludes=commons-collections:commons-collections
找出commons-collections:commons-collections包被项目中那些父包依赖,结果如下:
[INFO] com.bstek.ureport:ureport2-console:war:2.3.0-SNAPSHOT
[INFO] \- org.mybatis.spring.boot:mybatis-spring-boot-starter:jar:2.2.2:compile
[INFO] \- org.springframework.boot:spring-boot-starter:jar:2.6.3:compile
[INFO] +- org.springframework.boot:spring-boot:jar:2.6.3:compile
[INFO] \- org.springframework.boot:spring-boot-autoconfigure:jar:2.6.3:compile
[INFO] \- (org.springframework.boot:spring-boot:jar:2.6.3:compile - omitted for duplicate)
2.不同依赖包依赖相同包但是版本不一致:
将不同依赖的相同依赖包剔除调,
<exclusions> <exclusion> <groupId>commons-collections</groupId> <artifactId>commons-collections</artifactId> </exclusion> </exclusions>
然后在外面插入要使用的版本依赖:
<dependency> <groupId>commons-collections</groupId> <artifactId>commons-collections</artifactId> <version>3.2.2</version> </dependency>
3.docker file 中基础镜像的组件的漏洞修复,升级组件就可以:
以ubuntu 为例:
3.1 修改sources.list
sed -i "s/archive.ubuntu.com/mirrors.aliyun.com/g" /etc/apt/sources.list
3.2 更新源文件
apt-get update
3.3升级基础组件
apt-get upgrade -y
4.删除全部的镜像:
docker image prune -a -f