简体   繁体   中英

Modify spring cloud config server in the client

I have a spring boot powered spring cloud application with a configuration server running seperately on port say 8001 on localhost.

Meanwhile, location has been specified in the config client applications/micro services as below in the bootstrap.yml file of the client project.

spring:
  cloud:
    config:
      uri: http://localhost:8001

This works absolutely fine.

However when i want to deploy the whole application on different setups, i would need to run the config server on different IPs and Ports.

In that case i can not go and change the IP:Port information of the config server in all the projects, rebuild the jar and deploy them. In fact in most scenarios, Jenkins build the Jars by itself on different environment.

How can we handle such situation? Can we specify an environment variable in the bootstrap.yml, if yes how to do it?

Any suggestion?

Br,

AJ

You can definitely use environment variables in your bootstrap.yml file:

spring:
  cloud:
    config:
      uri: http://${configServerHost}:${configServerPort}

When you launch your application you only have to add -DconfigServerHost=localhost -DconfigServerPort=8001

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM