如何在 Spring 启动时从 Eureka 服务器上的 Grails 注册 eureka 客户端

How to register eureka client from Grails on eureka server in Spring boot

我想在 spring 启动的 eureka 服务器上注册我的 Grails 2.4.4 中的 eureka 客户端。

我已经在同一个 eureka 服务器上从 spring 启动注册了另一个 eureka 服务,它工作正常。 当我 运行 grails 应用程序时,它给我一个错误:

| Error 2018-02-21 17:29:39,765 [localhost-startStop-1] ERROR aws.ConfigClusterResolver  - Cannot resolve to any endpoints from provided configuration: {defaultZone=[]}
| Error 2018-02-21 17:29:39,771 [localhost-startStop-1] ERROR transport.EurekaHttpClients  - Initial resolution of Eureka server endpoints failed. Check ConfigClusterResolver logs for more info
| Error 2018-02-21 17:29:39,841 [localhost-startStop-1] ERROR discovery.DiscoveryClient  - DiscoveryClient_UNKNOWN/pawan - was unable to refresh its cache! status = There is no known eureka server; cluster server list is empty
Message: There is no known eureka server; cluster server list is empty
    Line | Method
->>  107 | execute                          in com.netflix.discovery.shared.transport.decorator.RetryableEurekaHttpClient
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|    134 | getApplications                  in com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator
|    137 | execute . . . . . . . . . . . .  in com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator
|     77 | execute                          in com.netflix.discovery.shared.transport.decorator.SessionedEurekaHttpClient
|    134 | getApplications . . . . . . . .  in com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator
|   1051 | getAndStoreFullRegistry          in com.netflix.discovery.DiscoveryClient
|    965 | fetchRegistry . . . . . . . . .  in     ''
|    414 | <init>                           in     ''
|    269 | <init> . . . . . . . . . . . . . in     ''
|    265 | <init>                           in     ''
|    257 | <init> . . . . . . . . . . . . . in     ''
|     31 | initializeEurekaClient           in EurekaConfiguration
|     20 | doCall . . . . . . . . . . . . . in BootStrap$_closure1
|    327 | evaluateEnvironmentSpecificBlock in grails.util.Environment
|    320 | executeForEnvironment . . . . .  in     ''
|    296 | executeForCurrentEnvironment     in     ''
|    266 | run . . . . . . . . . . . . . .  in java.util.concurrent.FutureTask
|   1149 | runWorker                        in java.util.concurrent.ThreadPoolExecutor
|    624 | run . . . . . . . . . . . . . .  in java.util.concurrent.ThreadPoolExecutor$Worker
^    748 | run                              in java.lang.Thread

这是我的 application.properties 文件:

#Grails Metadata file
#Grails Metadata file

#Grails Metadata file
#Grails Metadata file
#Fri Jan 19 17:25:36 IST 2018
app.grails.version=2.4.4
app.name=GrailsMicroservice
app.version=0.1
#app.port=8080
eureka.region = default
eureka.vipAddress = localhost
eureka.port = 1116eureka.name=Grails-Service
eureka.hostname=localhost
eureka.preferSameZone=true
eureka.shouldUseDns=false
eureka.serviceUrl.default=http://localhost:1116/eureka/

任何帮助都将不胜感激。

谢谢!

不确定这是您问题中的错字还是真正的错误,但 eureka.port = 1116eureka.name=Grails-Service 行应该是:

eureka.port = 1116
eureka.name=Grails-Service

以下是我应用于此问题的发现。但是,我在 google 上进行了大量搜索,以使其回到正轨。

第 1 步: 创建一个名为 eureka-client.properties

的文件

第 2 步: 现在从 application.properties 文件中删除您的配置代码并将其粘贴到新创建的文件中。

第 3 步: 在那里传递你的尤里卡端口,当然 serviceId 在这个文件中。

配置代码:

app.grails.version=2.4.4
app.name=GrailsMicroservice
app.version=0.1
#app.port=8080
eureka.region = default
eureka.vipAddress = localhost
eureka.port = 1116
eureka.name=Grails-Service
eureka.hostname=localhost
eureka.preferSameZone=true
eureka.shouldUseDns=false
eureka.serviceUrl.default=http://localhost:1116/eureka/

现在保存更改并 运行 您的申请。它将连接到您的 Eureka 服务器。刷新您的 Eureka 主页后,您会在那里找到它。