52ky 发表于 2022-5-4 13:33:05

Dockerize 微服务未在 Eureka 服务器中注册

问题
我的微服务运行良好。在开发过程中

在 Eureka 名称服务器上正确注册。当我部署我的

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 1 ---
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-

名称服务器:8761/eureka/
Please help me to register my micro-service in the eureka
server.
回答
我认为它应该是文档中所述的 eureka.client.serviceUrl.defaultZone ,而不是 eureka.client.service-url.default-zone 。您的应用程序未使用此属性,因此它回退到 localhost:8761 的默认值



页: [1]
查看完整版本: Dockerize 微服务未在 Eureka 服务器中注册