我在启动服务时发生端口冲突,并且配置服务已在运行。我目前正在使用Spring Boot 1.2.3.RELEASE和Spring Cloud 1.0.0.RELEASE(试用1.0.1.RELEASE,同样的问题)。Spring Cloud端口冲突8888
如果我在端口8888启动配置服务器,然后尝试启动另一个服务,它将尝试启动端口8888,即使我指定了另一个端口。奇怪的是,这在Mac OS中不会发生,它确实发生在Windows和Linux中。
如果我启动服务,然后配置服务器,那么它一切运作良好。该服务分配了不同于8888的端口和配置服务端口8888.
我尝试过不同版本的Spring云和Spring Boot,也有不同的配置。我尝试了post上的建议,但他们没有奏效。
关于如何解决这个问题的任何想法?
-
我设法通过配置服务器去除从application.yml
的server.port
并将其移动到bootstrap.yml
解决端口冲突。我还从application.yml
中删除了,客户服务,并将其移至bootstrap.yml
。下面你可以看到配置文件当前的状态。
这些都是在配置服务配置文件:
bootstrap.yml
server:
port: 8888
info:
name: "Config Service"
spring:
application:
name: config-service
profiles:
active: native
cloud:
config:
enabled: true
server:
git:
uri: <url to config repo>
application.yml
management:
context-path: /admin
info:
configuration: "Read From Config Service application.yml"
endpoints:
restart:
enabled: true
shutdown:
enabled: true
health:
sensitive: false
logging:
level:
com.netflix.discovery: 'OFF'
org.springframework.cloud: 'DEBUG'
eureka:
instance:
leaseRenewalIntervalInSeconds: 10
leaseExpirationDurationInSeconds: 5
preferIpAddress: false
statusPageUrlPath: /admin/info
healthCheckUrlPath: /admin/health
metadataMap:
hostname: ${vcap.application.application_uris[0]}
instanceId: ${vcap.application.instance_id:${spring.application.name}:${spring.application.instance_id:${random.value}}}
client:
registerWithEureka: true
fetchRegistry: true
serviceUrl:
defaultZone: http://127.0.0.1:8761/eureka/
在的配置客户服务是:
bootstrap.yml
server:
port: 0
info:
name: "Client Service"
spring:
application:
name: serviceC
profiles:
active: native
cloud:
config:
enabled: true
failFast: true
env: default
label: master
uri: http://localhost:8888
的application.yml是空的。
现在我有另一个问题。在Linux中,客户端正在从application.yml
文件中获取配置服务器(端口冲突的起源)中的配置,并在Mac OS中从配置的git存储库中获取该配置。
什么应该是正确的行为?
您需要发布您的配置,因为运行服务器的端口全部是弹簧引导的。 – spencergibb
由于某种原因,我还没弄明白,配置服务和客户端在Mac OS上的表现与Linux中的表现不同。 我将发布配置。 – Oreste