The following method did not exist: reactor.core.publisher.Operators.liftPublisher解決辦法

問題

運行spring application出現下面錯誤:

INFO - BeanFactory id=2d5128aa-061c-3cc9-96bb-2ab919339c49
ERROR - 

***************************
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:

    org.springframework.cloud.sleuth.instrument.reactor.ReactorSleuth.scopePassingSpanOperator(ReactorSleuth.java:71)

The following method did not exist:

    reactor.core.publisher.Operators.liftPublisher(Ljava/util/function/BiFunction;)Ljava/util/function/Function;

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

    jar:file:/D:/Program%20Files%20(x86)/mvnrepo/repository/io/projectreactor/reactor-core/3.2.12.RELEASE/reactor-core-3.2.12.RELEASE.jar!/reactor/core/publisher/Operators.class

It was loaded from the following location:

    file:/D:/Program%20Files%20(x86)/mvnrepo/repository/io/projectreactor/reactor-core/3.2.12.RELEASE/reactor-core-3.2.12.RELEASE.jar


Action:

Correct the classpath of your application so that it contains a single, compatible version of reactor.core.publisher.Operators


Process finished with exit code 1

原因

根據報錯信息感覺應該是reactor-core依賴衝突的錯誤,利用idea全局搜索發現是spring-cloud-sleuth-stream等jar包依賴reactor-core, 下面包依賴於3.2.11.RELEASE和3.2.12.RELEASE兩個不同版本.

在這裏插入圖片描述

解決辦法

在pom.xml指定同一個版本的依賴
例如:

<dependencyManagement>
		<dependency>
                <groupId>io.projectreactor</groupId>
                <artifactId>reactor-core</artifactId>
                <optional>true</optional>
                <version>3.2.11.RELEASE</version>
         </dependency>
</dependencyManagement>

另外去除某個包的依賴可以用exclusions標籤進行去除,如下:
	<dependency>
			<groupId>jaxen</groupId>
			<artifactId>jaxen</artifactId>
			<version>1.1.1</version>
			<exclusions>
				<exclusion>
					<groupId>xerces</groupId>
					<artifactId>xercesImpl</artifactId>
				</exclusion>
			</exclusions>
	</dependency>


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章