1
votes

I have a requirement to retrieve the property files with environment name distinguishing those.

Config server is listening to this repo (https://github.com/tpande1/spring-cloud-config-repo/tree/master) which has : config-client-dev.properties, config-client-sbx.properties, config-client-test.properties and config-client-prod.properties

In Client Server i have the below config to read from the above github repo. How can i read these different properties with the environment specified in my Client Application?

Sample Rest Code:

@GetMapping("/message") //Pick message(SBX, DEV, Test, PROD) from the propertyfile from github
public String getMessage() {

    return message;

}

bootstrap.yml:

spring: profiles: dev application: name: config-client cloud: config: uri: http://localhost:1000 //Config server port profile: sbx, dev, test, prod

management.endpoints.web.exposure.include: "*"

1
Added the Spring Profile to the code and application.yml but it doesn't seem to be working. application.properties : spring.profiles.active=dev Rest Code: @Profile("dev") @GetMapping("/message") public String getMessage() { return message; }Tarun Pande
can you update your issue rather than coding in a comment?spencergibb

1 Answers

0
votes

You can add multiple active profiles in your bootstrap yaml file. In the option where you have spring.profiles.active and in your config server, you can add search patterns for each profile.

As mentioned in the below link in Pattern matching section. https://cloud.spring.io/spring-cloud-config/multi/multi__spring_cloud_config_server.html