Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/maven/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring 弹簧-避免混合版本_Spring_Maven_Spring Boot_Spring Data - Fatal编程技术网

Spring 弹簧-避免混合版本

Spring 弹簧-避免混合版本,spring,maven,spring-boot,spring-data,Spring,Maven,Spring Boot,Spring Data,在运行Spring boot应用程序期间,我遇到以下错误: 试图调用方法org.springframework.web.reactive.function.client.WebClient.builder()Lorg/springframework/web/reactive/function/client/WebClient$builder;但它并不存在。其类org.springframework.web.reactive.function.client.WebClient可从以下位置获得: j

在运行Spring boot应用程序期间,我遇到以下错误:

试图调用方法
org.springframework.web.reactive.function.client.WebClient.builder()Lorg/springframework/web/reactive/function/client/WebClient$builder;但它并不存在。其类org.springframework.web.reactive.function.client.WebClient可从以下位置获得:

jar:file:/C:/Users/Wicia/.m2/repository/org/springframework/spring-web-reactive/5.0.0.M4/spring-web-reactive-5.0.0.M4.jar!/org/springframework/web/reactive/function/client/WebClient.class
它是从以下位置加载的:

file:/C:/Users/Wicia/.m2/repository/org/springframework/spring-web-reactive/5.0.0.M4/spring-web-reactive-5.0.0.M4.jar
行动:

Correct the classpath of your application so that it contains a single, compatible version of org.springframework.web.reactive.function.client.WebClient

我发现了一个线索,我应该为所有工件指定通用的spring版本(而不是混合使用),但是如何做到呢

这是我的pom.xml:

<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-core</artifactId>
    <version>5.0.0.M4</version>
</dependency>
<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-web</artifactId>
    <version>5.0.1.RELEASE</version>
</dependency>
<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-web-reactive</artifactId>
    <version>5.0.0.M4</version>
</dependency>
<dependency>
    <groupId>org.springframework.data</groupId>
    <artifactId>spring-data-cassandra</artifactId>
    <version>2.1.0.RELEASE</version>
</dependency>
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-web</artifactId>
    <version>2.0.5.RELEASE</version>
</dependency>

org.springframework
弹簧芯
5.0.0.M4
org.springframework
弹簧网
5.0.1.发布
org.springframework
弹簧网反应式
5.0.0.M4
org.springframework.data
弹簧数据卡桑德拉
2.1.0.1发布
org.springframework.boot
SpringBootStarterWeb
2.0.5.1发布

如果依赖项由Spring管理,则不要在pom.xml中定义依赖项版本。相反,请使用
spring boot starter父级
作为父级

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.0.5.RELEASE</version>
</parent>

<dependencies>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-core</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-web</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-web-reactive</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.data</groupId>
        <artifactId>spring-data-cassandra</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
<dependencies>

org.springframework.boot
spring启动程序父级
2.0.5.1发布
org.springframework
弹簧芯
org.springframework
弹簧网
org.springframework
弹簧网反应式
org.springframework.data
弹簧数据卡桑德拉
org.springframework.boot
SpringBootStarterWeb

SpringBoot父级为几乎所有流行的依赖项定义了版本,因此默认情况下可以跳过定义版本。只有在出现POM错误时才定义它(这意味着您添加了一个不由Spring Boot管理的唯一依赖项)

很好的解决方案,谢谢:)现在我添加了工件“Spring web Responsive”的版本,因为“org.springframework.web.Responsive”中的一些类我们丢失了,但仍然发生此错误:/I我不知道该软件包是什么,但mvnrepository中该软件包的最新版本是5.0.0.M4。一般建议:不要使用版本,除非您有很好的理由,并且您确实知道自己在做什么!:)您应该使用
springwebflux
而不是
springwebreactive
@Selindek好的,我只是想知道这样的场景-我想将类X添加到我的项目中。我在maven存储库中搜索它,在工件Y版本Z下找到了它,现在是什么-如何确定我应该使用哪些版本的依赖项,哪些不应该?(一定有一些非常聪明的家伙现在怎么做:)你正在使用Spring Boot。。。那就不要乱搞版本了。为
spring boot starter父级
使用一个版本,它应该是您的父级或pom中的
dependencyManagement
部分中的导入。所有其他版本将由Spring Boot管理。