classNotFoundException:com.netflix.config.cacheddynamicintpr



SpringBoot 2.1.4.RELEASE应用程序,带有Spring-Cloud-Starter-Netflix-ribbon 2.1.1.Release依赖。

试图在测试应用程序启动期间运行春季集成测试(使用@SpringBootTest(。 Caused by: java.lang.ClassNotFoundException:com.netflix.config.CachedDynamicIntProperty

项目中使用的Maven云依赖性:

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.1.4.RELEASE</version>
</parent>
    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-openfeign</artifactId>
        <version>2.1.1.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-netflix-hystrix</artifactId>
        <version>2.1.1.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-netflix-ribbon</artifactId>
        <version>2.1.1.RELEASE</version>
    </dependency>

测试属性文件:

feign.hystrix.enabled=true eureka.client.enabled=false ribbon.eureka.enabled=false some-my-mocked-service.ribbon.listOfServers=localhost:${mocked.port}

例外:

Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.netflix.loadbalancer.ILoadBalancer]: Factory method 'ribbonLoadBalancer' threw exception; nested exception is java.lang.NoClassDefFoundError: Lcom/netflix/config/CachedDynamicIntProperty;
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185)
    at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:622)

运行mvn dependency:tree -Dverbose并检查树是否版本冲突 - 看起来像 Spring-Cloud-Starter-openfeign and 文物使用不同版本的 Archaius-Core

最新更新