我使用Spring云Brixton.M4和spring boot是v1.3.1,使用eureka第一种方法,应用程序在随机端口server.port = 0上启动,但是它使用eureka服务器在端口0注册它。 这是我的bootstrap.properties文件
server.port=0
spring.application.name=course-composite-service
spring.cloud.config.fail-fast=true
spring.cloud.config.label=config-dev
spring.cloud.config.discovery.enabled=true
spring.cloud.config.discovery.serviceId=config-server
eureka.client.serviceUrl.defaultZone=http://localhost:8002/eureka/
并低于其日志
2016-01-11 18:36:50.286 INFO 17233 --- [nfoReplicator-0] com.netflix.discovery.DiscoveryClient : DiscoveryClient_COURSE-COMPOSITE-SERVICE/192.168.17.178:course-composite-service:0: registering service...
2016-01-11 18:36:50.288 INFO 17233 --- [ main] .w.c.c.CourseCompositeServiceApplication : Started CourseCompositeServiceApplication in 5.325 seconds (JVM running for 5.856)
2016-01-11 18:36:50.321 INFO 17233 --- [nfoReplicator-0] com.netflix.discovery.DiscoveryClient : DiscoveryClient_COURSE-COMPOSITE-SERVICE/192.168.17.178:course-composite-service:0 - registration status: 204
和eureka仪表板显示
COURSE-COMPOSITE-SERVICE UP (1) - 192.168.17.178:course-composite-service:0
为什么它没有注册实际端口运行? 我提供了来自配置服务器的其他eureka配置
eureka.client.register-with-eureka=true
eureka.instance.leaseRenewalIntervalInSeconds=10
eureka.instance.leaseExpirationDurationInSeconds=5
eureka.instance.preferIpAddress=false
eureka.instance.metadataMap.hostname=${vcap.application.application_uris[0]}
eureka.instance.metadataMap.instanceId=${vcap.application.instance_id:${spring.application.name}:${spring.application.instance_id:${random.value}}}