我很新Netflix Eureka和SpringBoot。我建立了一个非常简单的Eureka服务器和客户端,以便了解他们如何在发现方面获得智慧。尤里卡服务器会正常加载,因为我会在进入本地主机时看到UI:8761/JSONException使用Netflix Eureka
我正在Eclipse的Tomcat上运行这两个实例。
我构建的Eureka客户端是免费的代码,因为它只运行SpringBoot应用程序和正确的注释。关于尤里卡服务器的相同内容。
当我运行客户端,运行服务器后,我得到以下堆栈。我跑过网络获得一些解释,但我没有找到任何解释。你知道是什么导致这些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 {
\t \t public static void main(String[] args) {
\t 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 {
\t public static void main(String[] args) {
\t \t SpringApplication.run(EurekaClientApp.class, args);
\t }
}
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
eureka-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/