2017-08-28 181 views
2

我正在尝试向Eureka注册我的Java服务 - 没有运气。我有一个使用Spark-Java框架的现有代码库,因此'只添加两行Spring注释,瞧!不幸的是,这些例子对我没有帮助。如何配置Eureka客户端和服务属性?

我读了Eureka Configuration文档,创建灵光一现,conf目录下,并把下面两个文件尤里卡-conf的:

  • eureka-client.properties
  • eureka-service.properties

我添加了eureka_conf路径到我的$ CLASSPATH变量与export CLASSPATH=.:${CLASSPATH}:${EUREKA_CONF}/eureka-client.properties:${EUREKA_CONF}/eureka-service.properties

我复制粘贴的内容属性文件从here。所以,他们是这样的:

#eureka-client.properties 
eureka.registration.enabled=false 
eureka.preferSameZone=true 
eureka.shouldUseDns=false 
eureka.serviceUrl.default=http://localhost:8080/eureka/v2/ 
eureka.decoderName=JacksonJson 

#eureka-service.properties 
eureka.region=us-west-1 
eureka.name=qb-acm 
eureka.vipAddress=mysampleservice.mydomain.net 
eureka.port=8001 
eureka.preferSameZone=true 
eureka.shouldUseDns=false 
eureka.serviceUrl.default=http://localhost:8080/eureka/v2/ 

你可以看到,我改变了eureka.name和eureka.region在日志中查看是否被发现或没有的属性。他们没有被发现。

当我开始我的服务,我看到com.netflix.discovery.internal.util.Archaius1Utils抛出以下警告:

Cannot find the properties specified : eureka-client. This may be okay if there are other environment specific properties or the configuration is installed with a different mechanism.

其次是这样的:INFO com.netflix.discovery.DiscoveryClient - Initializing Eureka in region us-east-1

我创建了一个示例尤里卡服务器和客户端(与Spring)只是为了做一个例子,并注册了Spring客户端。现在,我试图让我的非Spring Java服务注册到本地的Eureka服务器。我的最终目标是将此服务设置为注册并将心跳发送到位于Pivotal上的远程Eureka服务器。

  1. 我在做什么错误设置属性:

    其他错误可能是有用的读者:

    [main] ERROR com.netflix.discovery.shared.resolver.aws.ConfigClusterResolver - Cannot resolve to any endpoints from provided configuration: {defaultZone=[]} 
    [main] ERROR com.netflix.discovery.shared.transport.EurekaHttpClients - Initial resolution of Eureka server endpoints failed. Check ConfigClusterResolver logs for more info 
    

    所以,我的问题是?

  2. 我在很多例子中看到他们有一个application.ymlmanifest.yml文件。在Eureka配置中,.yaml文件 是什么?它是 文件的替代品吗?

编辑:我发现this answer解释了yaml文件。 Application.yml被Spring引导使用,Manifest.yml被云代工CLI使用。

  1. 什么应该是我的本地环境和Pivotal上的eureka.vipAddress?

**编辑:我发现,与试验和错误,在本地这设置为http://localhost:yourport和PCF它应该是应用程序名称。 localhostservice-name都不对应于物理网络接口。哦,我终于知道虚拟ip是什么**

让我知道是否需要更多信息。预先感谢您的帮助。

回答

0

看来,你的配置文件没有在启动过程中找到。尤里卡配置文件必须位于类路径中。有时它们不会打包到jar文件中。请确保您的罐子中的文件能够分析您罐子的内容。

你在用maven建造吗?然后在你的pom-File的build部分添加一个资源/包含块,以确保包含配置文件。

某些尤里卡属性可以在application.yml文件中设置,该文件与applicaiton.properties相同,但您正在编写配置的格式除外。我不确定是否有yaml的eureka-client.properties等价物。首先运行* .properties,然后尝试是否理解yaml。

相关问题