我很新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/