loading multiple properties with config-server

2019-05-28 21:57发布

问题:

I have successfully tested loading properties from SVN repository, currently in my config server i have provided the URI and default-label: trunk and i have application specific property under trunk. below is the contents of my consuming application's application.yml and able to pull the properties successfully

spring:
  application:
    name: foo-development
  cloud:
    config:
      uri: http://localhost:${config.port:8888}

now i have a shared property in different folder thats shared across other applications as well, so how do i load this into my application along with my application specific

回答1:

You can create a general application.yml in the root folder of SVN.

See the example config repo here: https://github.com/spring-cloud-samples/config-repo

And here is an example consumer https://github.com/spring-cloud-samples/customers-stores/blob/master/rest-microservices-store/src/main/resources/bootstrap.yml

The customer-stores project will read from application.yml and also from stores.yml in the repo.

To confirm, check the /env URL if you have actuator added and you should see two configService entries