问题
I have all the common properties in application.properties file. version specific properties are in version1 and version2 folders in github.
order-service(base folder)
application.properties
version1
app-dev.properties
version2
app-dev.properties
How can I set the config in application.yml file to ensure cloud config server returns version 1 props along with with common props when version1 url is hit.Below is the config that I have now to fetch props from base folder and how could it be modified to achieve the above.
spring:
cloud:
config:
server:
git:
uri: https://github.company.com/orders-properties
username: orders
password: orders
search-paths: order-service
回答1:
If I understood correctly this is what you need.
Lets say you have two apps called app-dev-v1 and app-dev-v2.
You need to add a bootstrap.yml file inside the resources folder and add this property on both the apps.
For app-dev-v1
spring:
application:
name: app-dev-v1
For app-dev-v2
spring:
application:
name: app-dev-v2
In the repository you can have a .yml or .properties file like this inside version1 and version2 folder.
app-dev-v1.yml and app-dev-v2.yml
Also for config server you need to add the search paths:
spring:
cloud:
config:
server:
git:
uri: https://github.company.com/orders-properties
username: orders
password: orders
search-paths: order-service,version*
来源:https://stackoverflow.com/questions/37554205/spring-cloud-config-versioning