spring cloud netflix - 使用没有Jersey的EurekaClient会抛出无法识别的字段异常

时间:2018-03-05 11:38:07

标签: spring-cloud netflix-eureka spring-cloud-netflix

我有一个eureka服务器 - demo-eurekaserver - 以及两个注册服务 - demo-eurekaclientdemo-feignclient全部使用

  • <View style={{ flexDirection: 'row', width: 200, height : 100 }}> <View style={{ borderWidth: 2, flex: 1, height: 100, }}> <Text>flex: 1, height: 80</Text> </View> <View style={{ borderWidth: 2, width: 100, height: '100%', justifyContent : 'center' }} > <Text style={{textAlign : 'center'}} >width: 100, height: 100%, justifyContent: center</Text> </View> </View>
  • spring-boot-starter-parent: 2.0.0.RELEASE

其中一项服务(spring-cloud version: Finchley.BUILD-SNAPSHOT)使用eureka客户端依赖项

demo-feignclient

它注册正常。

其他服务 <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId> </dependency> 使用demo-eurekaclient依赖关系而不是as documented here

EuerkaClient

并抛出 <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-eureka</artifactId> <version>1.4.3.RELEASE</version> <exclusions> <exclusion> <groupId>com.sun.jersey</groupId> <artifactId>jersey-client</artifactId> </exclusion> <exclusion> <groupId>com.sun.jersey</groupId> <artifactId>jersey-core</artifactId> </exclusion> <exclusion> <groupId>com.sun.jersey.contribs</groupId> <artifactId>jersey-apache-client4</artifactId> </exclusion> </exclusions> </dependency>

这是整个堆栈跟踪

Unrecognized field "overriddenStatus" (class com.netflix.appinfo.InstanceInfo)

1 个答案:

答案 0 :(得分:-1)

如果您继续学习本教程https://spring.io/guides/gs/service-registration-and-discovery/,您将看到由spring parent维护的依赖项。截至目前,Spring netflix的版本为2.0.0.M7,因此您可以切换到该版本。这应该使图片更清晰,然后您可以使用选定的依赖关系图切换回您自己的父级。

即使看起来球衣和杰克逊会发生碰撞,但事实并非如此。所以,放下球衣排除。我遇到了同样的问题。

同样为了避免旧杰克逊注释的拉动,请指定它...当前jacskon为2.9.4,但由于某种原因,注释将拉至2.8.6。所以指定两者。

<dependency>
    <groupId>com.fasterxml.jackson.core</groupId>
    <artifactId>jackson-core</artifactId>
    <version>${jackson-version}</version>
</dependency>
<dependency>
    <groupId>com.fasterxml.jackson.core</groupId>
    <artifactId>jackson-annotations</artifactId>
    <version>${jackson-version}</version>
</dependency>

使用的版本(抱歉,这些都是我需要的,您可能需要更少):

<properties>
    <java.version>1.8</java.version>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <spring-version>5.0.4.RELEASE</spring-version>
    <spring-boot-version>2.0.0.RELEASE</spring-boot-version>
    <spring-netflix-version>2.0.0.M7</spring-netflix-version>
    <junit-version>5.0.3</junit-version>
    <reactor-test-version>3.0.7.RELEASE</reactor-test-version>
    <reactor-netty-version>0.7.3.RELEASE</reactor-netty-version>
    <netty-all-version>4.1.21.Final</netty-all-version>
    <hibernate-validator-version>5.2.5.Final</hibernate-validator-version>
    <log4j-version>2.0.2</log4j-version>
    <javax-servlet-version>3.0.1</javax-servlet-version>
    <javax-el-version>3.0.1-b04</javax-el-version>
    <glassfish-el-version>3.0.1-b09</glassfish-el-version>
    <aspectj-version>1.8.13</aspectj-version>
    <commons-lang-version>3.7</commons-lang-version>
    <reactor-core-version>3.1.4.RELEASE</reactor-core-version>
    <jackson-version>2.9.4</jackson-version>
    <gson-version>2.8.2</gson-version>
</properties>

以下是我的客户端pom(再次,您可以忽略webflux及其dep-s):

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter</artifactId>
    <version>${spring-boot-version}</version>
    <exclusions>
        <exclusion>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-tomcat</artifactId>
        </exclusion>
        <exclusion>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-api</artifactId>
        </exclusion>
        <exclusion>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-to-slf4j</artifactId>
        </exclusion>
    </exclusions>
</dependency>
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-test</artifactId>
    <version>${spring-boot-version}</version>
    <scope>test</scope>
</dependency>
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-data-mongodb-reactive</artifactId>
    <version>${spring-boot-version}</version>
</dependency>
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-webflux</artifactId>
    <version>${spring-boot-version}</version>
    <exclusions>
        <exclusion>
            <groupId>org.hibernate.validator</groupId>
            <artifactId>hibernate-validator</artifactId>
        </exclusion>
    </exclusions>
</dependency>
<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
    <version>${spring-netflix-version}</version>
</dependency>

使用以下服务器pom:

<dependencies>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-core</artifactId>
        <version>${spring-version}</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
        <version>${spring-netflix-version}</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-autoconfigure</artifactId>
        <version>${spring-boot-version}</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <version>${spring-boot-version}</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>com.fasterxml.jackson.core</groupId>
        <artifactId>jackson-core</artifactId>
        <version>${jackson-version}</version>
    </dependency>
    <dependency>
        <groupId>com.google.code.gson</groupId>
        <artifactId>gson</artifactId>
        <version>${gson-version}</version>
    </dependency>
</dependencies>