spring -cloud-config-server makes several REST APIs available, allowing you to directly request the properties file:
$ hostname:port/{label}/{name}-{profiles}.properties]
You can dynamically use any label of your choice if it matches an existing label on git.
For example, for extraction application.propertiestagged v1in git:
$ http://${hostname}:${port}/v1/application.properties
Config Server REST API:
- /{name}/{profiles}/{label:. *
- /{}/{} - {} .properties
- /{} - {} .json
- /{}/{} - {} .json
- /{}/{} - {} .yml
- /{}/{} - {} .yaml
- /{} - {} .yml
- /{} - {} .yaml
- /{}/{:.. [^ -]}
- /{} - {} .properties
- /{}/{}/{}/**
spring-cloud-server git. git v1 v2 ( remote):
label v1:
http:
> testproperty: remotevalue-v1
label v2:
http:
> testproperty: remotevalue-v2
:
http:
> testproperty: remotevalue-master
Java-
, , java- cloud-config-server ( , http-):
@Autowired
EnvironmentController environmentController;
...
Environment labelled = environmentController.labelled("application", "remote", "v1");
Map<?, ?> keyValues = labelled.getPropertySources().get(0).getSource();