首页 > 其他分享 >如何解决jar包冲突

如何解决jar包冲突

时间:2022-11-15 11:02:03浏览次数:43  
标签:core reactor netty jar 冲突 io 解决 projectreactor

问题描述

APPLICATION FAILED TO START
***************************

Description:

An attempt was made to call a method that does not exist. The attempt was made from the following location:

    reactor.netty.transport.ServerTransport$DisposableBind.<init>(ServerTransport.java:494)

The following method did not exist:

    reactor.core.publisher.MonoSink.contextView()Lreactor/util/context/ContextView;

The calling method's class, reactor.netty.transport.ServerTransport$DisposableBind, was loaded from the following location:

    jar:file:/Users/yiwenjie/.m2/repository/io/projectreactor/netty/reactor-netty-core/1.0.19/reactor-netty-core-1.0.19.jar!/reactor/netty/transport/ServerTransport$DisposableBind.class

The called method's class, reactor.core.publisher.MonoSink, is available from the following locations:

    jar:file:/Users/yiwenjie/.m2/repository/io/projectreactor/reactor-core/3.3.22.RELEASE/reactor-core-3.3.22.RELEASE.jar!/reactor/core/publisher/MonoSink.class

The called method's class hierarchy was loaded from the following locations:

    reactor.core.publisher.MonoSink: file:/Users/yiwenjie/.m2/repository/io/projectreactor/reactor-core/3.3.22.RELEASE/reactor-core-3.3.22.RELEASE.jar

Action:

Correct the classpath of your application so that it contains compatible versions of the classes reactor.netty.transport.ServerTransport$DisposableBind and reactor.core.publisher.MonoSink

通过查询错误堆栈异常,我们发现jar包冲突

io/projectreactor/reactor-core/3.3.22.RELEASE/reactor-core-3.3.22.RELEASE.jar

io/projectreactor/netty/reactor-netty-core/1.0.19/reactor-netty-core-1.0.19.jar

解决方案

  • 强行引入需要的版本

    <dependency>
      <groupId>io.projectreactor.netty</groupId>
      <artifactId>reactor-netty-core</artifactId>
      <version>1.0.19</version>
    </dependency>
    
  • 排除不需要的版本

    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-data-redis</artifactId>
      <version>2.7.3</version>
      <exclusions>
        <exclusion>
          <groupId>io.projectreactor</groupId>
          <artifactId>reactor-core</artifactId>
        </exclusion>
      </exclusions>
    </dependency>
    

如何提前预知版本冲突问题?

安装maven的插件工具

image-20221115104210625

点击pom文件的依赖分析

image-20221115104309861

这些就是多个版本的冲突jar包

image-20221115104554707

标签:core,reactor,netty,jar,冲突,io,解决,projectreactor
From: https://www.cnblogs.com/ywjcqq/p/16891671.html

相关文章