我想用Spring Cloud自定义Eureka端口。 使用下面的默认端口,服务注册表看起来正确(在提供的GUI中)
spring:
application:
name: services-registry
server:
port: 8761
eureka:
instance:
hostname: localhost
nonSecurePort: ${server.port}
client:
register-with-eureka: true
fetch-registry: false
service-url:
default-zone: http://${eureka.instance.hostname}:${server.port}/eureka/
但是,如果我只是将server.port更改为8787,那么任何服务都无法注册,甚至服务注册表本身也无法注册。
2017-01-09 16:18:21.584 WARN 17496 --- [nfoReplicator-0] c.n.d.s.t.d.RetryableEurekaHttpClient : Request execution failure
2017-01-09 16:18:21.584 WARN 17496 --- [nfoReplicator-0] com.netflix.discovery.DiscoveryClient : DiscoveryClient_SERVICES-REGISTRY/xxx.org:services-registry:8787 - registration failed Cannot execute request on any known server
com.netflix.discovery.shared.transport.TransportException: Cannot execute request on any known server
...
2017-01-09 16:13:33.299 WARN 17496 --- [nfoReplicator-0] c.n.discovery.InstanceInfoReplicator : There was a problem with the instance info replicator
com.netflix.discovery.shared.transport.TransportException: Cannot execute request on any known server
有人可以解释这个问题并节省我的一天吗?谢谢!
答案 0 :(得分:9)
好的,得到它... service-url属性之后的标签(在YML中可以别名为serviceUrl)是HashMap KEY ,而不是属性标签。所以它必须以任何方式保存为Camel Case标签!
eureka.client.service-url.defaultZone=http://[myIP@]:8787/eureka