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两个不同版本.

The following method did not exist: reactor.core.publisher.Operators.liftPublisher解决办法_第1张图片

解决办法

在pom.xml指定同一个版本的依赖
例如:

<dependencyManagement>
		<dependency>
                <groupId>io.projectreactorgroupId>
                <artifactId>reactor-coreartifactId>
                <optional>trueoptional>
                <version>3.2.11.RELEASEversion>
         dependency>
dependencyManagement>

另外去除某个包的依赖可以用exclusions标签进行去除,如下:
	<dependency>
			<groupId>jaxengroupId>
			<artifactId>jaxenartifactId>
			<version>1.1.1version>
			<exclusions>
				<exclusion>
					<groupId>xercesgroupId>
					<artifactId>xercesImplartifactId>
				exclusion>
			exclusions>
	dependency>


你可能感兴趣的:(Spring)