我的微服务运行正常。在开发过程中 在Eureka-Naming服务器中正确注册。当我部署我的 service和eureka-server放入两个不同的容器中,我的微服务未在eureka-server中注册。我所有的 配置和属性文件如下-
Eureka-Service dockerfile-
------------------------------------------------------------------
FROM openjdk:8u181-jdk-stretch
MAINTAINER Test "support@softwaredeveloper.com"
EXPOSE 8761
COPY maven/netflix-eureka-naming-server-0.0.1-SNAPSHOT.jar
netflix-eureka-naming-server.jar
CMD ["java","-jar","netflix-eureka-naming-server.jar"]
------------------------------------------------------------
customer-account-mysql dockerfile-
-------------------------------------------------------------
FROM openjdk:8u181-jdk-stretch
MAINTAINER Test "support@softwaredeveloper.com"
EXPOSE 8100
COPY maven/customer-account-mysql-0.0.1-SNAPSHOT.jar customer-
account-mysql.jar
CMD ["java","-jar","customer-account-mysql.jar"]
---------------------------------------------------------------
Compose File for customer-account-mysql and Eureka Server
--------------------------------------------------------------
customer-account-mysql:
image: customer-account-mysql
networks:
- customer-network
ports:
- 8100:8100
depends_on:
- netflix-eureka-naming-server
netflix-eureka-naming-server:
image: netflix-eureka-naming-server
networks:
- customer-network
ports:
- 8761:8761
-------------------------------------------------------
Properties file of customer-account-mysql
-----------------------------------------------------
spring.application.name=customer-account-mysql
server.port=8100
eureka.client.service-url.default-zone=http://netflix-eureka-
naming-server:8761/eureka/
------------------------------------------------------------
Properties file of eureka-server
---------------------------------------------------------
spring.application.name=netflix-eureka-naming-server
server.port=8761
eureka.client.register-with-eureka=false
eureka.client.fetch-registry=false
eureka.server.enableSelfPreservation=false
---------------------------------------------------------
But customer-account-mysql service is not registering in the
Eureka-Server. I have inspect the log on the customer-account-
mysql container.
Following error I was getting..
Error--------------
----------------------------------------------------------------
2019-02-06 06:27:33.248 ERROR [customer-account-mysql,,,] 1 ---
[nfoReplicator-0] c.n.d.s.t.d.RedirectingEurekaHttpClient :
Request execution error. endpoint=DefaultEndpoint{
serviceUrl='http://localhost:8761/eureka/}
com.sun.jersey.api.client.ClientHandlerException:
java.net.ConnectException: Connection refused (Connection refused)
at com.sun.jersey.client.apache4.
ApacheHttpClient4Handler.handle(ApacheH
ttpClient4Handler.java:187) ~[jersey-apache-client4-
1.19.1.jar!/:1.19.1]
at
----------------------------------------------------------------
我的客户帐户MySQL正在尝试连接 http://localhost:8761/eureka/。我明确提到默认值的地方 客户帐户mysql属性文件中的区域。那是 eureka.client.service-url.default-zone = http://netflix-eureka- naming-server:8761 / eureka /
Please help me to register my micro-service in the eureka
server.
答案 0 :(得分:1)
我认为应该是{"CODEA"=>"text for first item", "CODEB"=>"text for next item", "CODEB2"=>"some more text", "CODEC"=>"yet more text"}
,而不是eureka.client.serviceUrl.defaultZone
。您的应用程序未使用该属性,因此它回退到默认值eureka.client.service-url.default-zone
答案 1 :(得分:0)
在客户端eureka服务上的docker-compose文件中,输入以下内容:
environment:
EUREKA_CLIENT_SERVICEURL_DEFAULTZONE: http://netflix-eureka-naming-server:8761/eureka/