We are using Spring Cloud Config Server to host all configurations for our Spring Boot applications. We want a huge JSON text to be retrieved from the Config Server.
Our current approach is to define the json text as a property value
myproperty.jsontext="{'name':'value'}"
Apart from defining the JSON text as a property value, is there any way to host & fetch it from the config server ?
Does Spring Cloud Config Server support a .json file ?
Update (additional Question):
Can i access the searchLocations property as follows ?
@Value("${spring.cloud.config.server.native.searchLocations}
while acessing, we keep getting the following error
Caused by: java.lang.IllegalArgumentException: Could not resolve placeholder 'spring.cloud.config.server.native.searchLocations' in string value "${spring.cloud.config.server.native.searchLocations}"
Our Spring application will support both JSON as well as XML. It will even support XML request with JSON response and vice versa.
Spring Cloud Config is Spring's client/server approach for storing and serving distributed configurations across multiple applications and environments. This configuration store is ideally versioned under Git version control and can be modified at application runtime.
json and place it inside of /src/main/resources/json/.
In the Project Explorer view, expand the plug-in project node. Expand the plugin folder node. Double-click the config. json file, or right-click the file and select Open with > PDK JSON Editor.
there's the possibility to serve arbitary files. It boils down to using the endpoint /{name}/{profile}/{label}/{path}
with {path}
being the actual filename... So e.g. /a-bootiful-client/default/master/myjson.json
will give you the file contents. However by default the content-type of the response will not be application/json
but text/html;charset=UTF-8
.
However it will also work with "Accept: application/json":
curl -H "Accept: application/json" http://localhost:8888/a-bootiful-client/default/master/a-bootiful-client.json
{
"propName":"propValue"
}
See the documentation here: http://cloud.spring.io/spring-cloud-static/spring-cloud-config/1.4.3.RELEASE/single/spring-cloud-config.html#_serving_plain_text
Since yaml
is a subset of Json
, you can store a Json
content inside of a Yaml
file.
yaml
, json
and properties
and everything works!I have tested this approach when integrating an existing Node.js app to Config Service where all the configs were in .json
file. So, I just renamed all of them and added to a Config Repo.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With