使用 Netflix Eureka 的 JSONException

JSONException using Netflix Eureka

我对 Netflix Eureka 和 SpringBoot 还很陌生。我构建了一个非常简单的 Eureka 服务器和客户端,以便了解它们如何在发现方面取得进展。当我去 localhost:8761/

时看到 UI 时,Eureka 服务器正常加载

我运行将这两个实例与 Eclipse 的 Tomcat 结合起来。

我构建的 Eureka 客户端没有代码,因为它只是 运行 带有适当注释的 SpringBoot 应用程序。关于 Eureka 服务器的相同内容。

当我 运行 客户端时,在 运行 连接服务器之后,我得到以下堆栈。我 运行 通过网络获得一些解释,但我没有找到任何解释。您知道是什么导致了这些 JSONObject 异常吗?

服务器端堆栈:http://pastebin.ca/2968955

客户端堆栈:http://pastebin.ca/2968957

这是我的代码:

EurekaServer.java :

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;

@SpringBootApplication
@EnableEurekaServer
public class EurekaServer {
  public static void main( String[] args ) {
         SpringApplication.run(EurekaServer.class, args);
    }
}

EurekaServer 的 application.yml :

spring:
  application:
    name: EurekaServer

server:
  port: 8761

eureka:
  instance:
    hostname: localhost
  client:
    registerWithEureka: false
    festRegistry: false
    serviceUrl:
      defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka/

EurekaClientApp.java :

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.web.bind.annotation.RestController;

@SpringBootApplication
@EnableEurekaClient
@RestController
public class EurekaClientApp {
 public static void main(String[] args) {
  SpringApplication.run(EurekaClientApp.class, args);
 }
}

EurekaClient 的 Application.yml :

spring:
  application:
    name: EurekaClient
    
eureka:
  client:
    serviceUrl:
      defaultZone: http://localhost:8761/eureka/
    registerWithEureka: true
    fetchRegistry: false
  instance:
    leaseRenewalIntervalInSeconds: 10
    metadataMap:
      instanceId: ${spring.application.name}:${spring.application.instance_id:${random.value}}

server:
  port: 8188

尤里卡-client.properties :

eureka.port=8188
eureka.vipAddress=productservice.mydomain.net
eureka.preferSameZone=true
eureka.shouldUseDns=false
eureka.availabilityZones=default
eureka.serviceUrl.defaultZone=http://localhost:8761/eureka/

因此,在尝试通过修改代码使其工作几个小时失败后,我查看了 pom.xml 文件并删除了附加到应用程序这一部分的依赖项。我把它们一个一个地放回去,验证它会做的修改,我发现我对 eureka 有错误的依赖性,因为我替换了我拥有的那个,例如com.netflix.eureka 由springboot提供的,例如spring-cloud-starter-eureka.