我们正在尝试在spring-cloud-consul上使用consul注册GCP compute engine应用程序,在那里它能够向领事注册应用程序,但是我们在应用程序中遇到了两个问题。以下是bootstrap.yaml
和server.yaml的应用程序,
application.yaml
server:
port: 10003
spring:
application:
name: hello-service
cloud:
consul:
enabled: true
inetutils:
useOnlySiteLocalInterfaces: true
endpoints:
actuator:
sensitive: false
bootstrap.yaml
spring:
cloud:
consul:
enabled: true
host: 10.160.0.18
port: 8500
discovery:
prefer-ip-address: true
consul服务:NewService {id ='hello-service-10003',name ='hello-service',tags = [secure = false],address ='consul-app-test.c.name-of-project.internal ',meta = null,port = 10003,enableTagOverride = null,check = Check {script ='null',interval ='10s',ttl ='null',http ='http://consul-app-test.c.name-of-project.internal:10003/actuator/health',method ='null',header = {},tcp ='null',timeout ='null',deregisterCriticalServiceAfter ='null',tlsSkipVerify = null,status ='null'},checks = null}
我在application.yaml和bootstrap.yaml中做了一些更改,这对我有用。
application.yaml
spring:
application:
name: hello-service
cloud:
consul:
discovery:
instanceId: ${spring.application.name}:${random.value}
health-check-critical-timeout: 3m
prefer-ip-address: true # disable if we want to use google cloud internal DNS
bootstrap.yaml
spring:
cloud:
consul:
enabled: true
host: 10.160.0.18
port: 8500