Search code examples
javaspringspring-bootspring-cloudspring-cloud-config

Spring Cloud Config Server With Non-Spring Application


So I have a Servlet/JSP web application. We used Ant scripts to build scripts to build properties for different environments, during deployment using loads of filtering. But we are now moving the application to build with Maven. We are thinking of using Spring Cloud Config as centralized repository for property files for all environments that we have. So primarily my question was:

  1. Can we use Spring Cloud Config Server to host properties and fetch it in a non-Spring application?

  2. Can we use Spring Cloud Config to fetch XML, XSD, Text files too? (This is a bit of stretch but just asking if its possible)

We don't plan to use GIT as repository for property, just use a filesystem.

Any pointers would be appreciated.


Solution

  • Spring Cloud Config Server provides an HTTP API that is described in the "Quick Start" section of the Spring Cloud Config documentation. You can use GET requests to fetch configuration properties for specific applications and profiles, e.g.:

    curl http://config-server-host:8888/my-application/dev
    

    Using the HTTP API allows you to integrate Config Server with applications that are not based on Spring.

    Spring Cloud Config Server can also return non-property files that are handled as "plain text". Please review section "Serving Plain Text" in the Spring Cloud Config documentation:

    The Config Server provides these through an additional endpoint at /{application}/{profile}/{label}/{path}, where application, profile, and label have the same meaning as the regular environment endpoint, but path is a path to a file name (such as log.xml).

    A curl request for a logback.xml file would therefore look as follows:

    curl http://config-server-host:8888/my-application/dev/logback.xml?useDefaultLabel