当前位置: 首页 > 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.xdnf.cn/news/347797.html

相关文章:

  • 17.thinkphp的分页功能
  • 开发者如何应对浏览器中的身份关联与反追踪问题?
  • 主成分分析(PCA)是什么?简易理解版
  • 使用Compose编排工具搭建Ghost博客系统
  • goner/otel 在Gone框架接入OpenTelemetry
  • [python] 函数1-函数基础
  • 软考职称政策再加码!已有多地发布通知!
  • SiC MOSFET同步Buck DC-DC变换器的宽频混合EMI滤波器设计
  • 【嵌入式开发-UART】
  • docker 安装 sqlserver2022 和注意点
  • 模拟散列表(算法题)
  • Vue3中emits和emit
  • Qwen3中的MoE是如何平衡专家负载的?
  • 跨线程和跨进程通信还有多种方式对比
  • JS 下载data:image/png;base64, 图片
  • 告别手动输入密码:基于SSHPass的自动化文件传输实践告别手动输入密码:基于SSHPass的自动化文件传输实践
  • Marin说PCB之器件的3D数模匹配失效案例
  • 在微程序控制器中,各概念之间的详细关系
  • IEEE出版|2025年物联网、数据科学与先进计算国际学术会议(IDSAC2025)
  • MyBatis 动态 SQL 完整笔记
  • 深泽多层电路在PCB行业中属于什么水平
  • laravel 使用异步队列,context带的上下文造成反序列化出问题
  • sql server限制用户只能访问特定表
  • PWN基础-ROP技术-ret2syscall-64位程序栈溢出利用
  • el-table合并单元
  • 【基础知识】李雅普诺夫方程与李雅普诺夫函数
  • 985高校查重率“隐性阈值”:低于5%可能被重点审查!
  • 从艾米・阿尔文看 CTO 的多面特质与成长路径
  • 英皇娱乐X乐华娱乐携手造星!“英皇乐华青少年艺人培训班”正式启动!
  • 深度学习-159-综述之混合专家模型和推理模型以及工作流和智能体的概念