当前位置: 首页 > news >正文

maven 依赖冲突异常分析

异常如下

Description:An attempt was made to call a method that does not exist. The attempt was made from the following location:com.google.common.cache.CacheBuilder.initialCapacity(CacheBuilder.java:353)The following method did not exist:com.google.common.base.Preconditions.checkState(ZLjava/lang/String;I)VThe calling method's class, com.google.common.cache.CacheBuilder, was loaded from the following location:jar:file:/Users/Zhuanz/Documents/software/apache-maven-3.8.1/maven-repository/com/google/guava/guava/30.1-jre/guava-30.1-jre.jar!/com/google/common/cache/CacheBuilder.classThe called method's class, com.google.common.base.Preconditions, is available from the following locations:jar:file:/Users/Zhuanz/Documents/software/apache-maven-3.8.1/maven-repository/com/google/collections/google-collections/1.0/google-collections-1.0.jar!/com/google/common/base/Preconditions.classjar:file:/Users/Zhuanz/Documents/software/apache-maven-3.8.1/maven-repository/com/google/guava/guava/30.1-jre/guava-30.1-jre.jar!/com/google/common/base/Preconditions.classThe called method's class hierarchy was loaded from the following locations:com.google.common.base.Preconditions: file:/Users/Zhuanz/Documents/software/apache-maven-3.8.1/maven-repository/com/google/collections/google-collections/1.0/google-collections-1.0.jarAction:Correct the classpath of your application so that it contains compatible versions of the classes com.google.common.cache.CacheBuilder and com.google.common.base.Preconditions

异常栈分析

com.google.common.cache.CacheBuilder.initialCapacity方法调用com.google.common.base.Preconditions.checkStatecom.google.common.cache.CacheBuilder.initialCapacity来自于/Users/Zhuanz/Documents/software/apache-maven-3.8.1/maven-repository/com/google/guava/guava/30.1-jre/guava-30.1-jre.jarcom.google.common.base.Preconditions.checkState方法来自于/Users/Zhuanz/Documents/software/apache-maven-3.8.1/maven-repository/com/google/collections/google-collections/1.0/google-collections-1.0.jar
分析过程
1、打印 classloader 发现类加载器一样
2、mvn:dependency 得到如下截图,由于 google-collections 比 guava 层级高,因此会加在google-collections jar 包中的Preconditions类
3、查看两个 jar 包中的字节码
javap -v -classpath guava-30.1-jre.jar com.google.common.base.Preconditions | grep -A 10 "checkState"
javap -v -classpath google-collections-1.0.jar com.google.common.base.Preconditions | grep -A 10 "checkState"
对比发现com.google.common.base.Preconditions类中的 checkState 方法没有com.google.common.base.Preconditions.checkState(ZLjava/lang/String;I)V

在这里插入图片描述
解决办法:去除 google-collection 的依赖即可。

http://www.dtcms.com/a/179046.html

相关文章:

  • Java基础
  • matlab稳定求解高精度二维对流扩散方程
  • 线代第二章矩阵第五、六、七节矩阵的转置、方阵的行列式、方阵的伴随矩阵
  • 初始图形学(8)
  • 图神经网络中的虚拟节点
  • Vue3快速入门/Vue3基础速通
  • neo4j官方示例
  • 【electron+vue】常见功能之——调用打开/关闭系统软键盘,解决打包后键盘无法关闭问题
  • flex-grow魔法
  • OSCP备战-kioptrix level _2详细分析
  • git的常用命令详解
  • Hex文件格式解析
  • numpy pandas
  • 【渗透测试】反序列化漏洞的原理、利用方式与防范措施
  • RabbitMQ学习(第二天)
  • [机器学习介绍与定义]机器学习-part1
  • [数据库之十三] 数据库索引之散列索引
  • 量子通信技术及其在信息安全中的应用:开启无条件安全通信的新时代
  • 视频添加字幕脚本分享
  • 【计算机网络 第8版】谢希仁编著 第四章网络层 题型总结2
  • Kubernetes 手动部署 Prometheus 学习计划
  • 笔记本电脑实现网线内网 + Wi-Fi外网同时使用的配置方案
  • 基于FPGA控制PCF8591开展ADC采样,以采样烟雾模块输出模拟电压为例(IIC通信)
  • 宴会综合生产实训室融合数字化宴会管理路径
  • flow-matching 之学习matcha-tts cosyvoice
  • 企业级UI测试的“双保险”:TestComplete的智能对象识别与详细报告功能
  • 本地聊天机器人部署方案
  • 安卓基础(静态方法)
  • 网络字节序 - 大端
  • Java的对象头:原理与源码详解