Kick start your own Spring Cloud Config Server with MongoDB

Spring Cloud Config Server MongoDB enables the seamless integration of the regular Spring Cloud Config Server with MongoDB to manage external properties for applications across all environments.

A Simple Config Server

Bootstrapping a configuration server with Spring Cloud Config Server MongoDB is just a matter of the following three steps.

1. Configure your pom.xml:

        <name>Spring Snapshots</name>
        <name>OJO Snapshots</name>

2. Create a standard Spring Boot application with the EnableMongoConfigServer annotation:

public class Application {
    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);

3. Configure the application’s spring.data.mongodb.* properties in application.yml:

      uri: mongodb://localhost/config-db


We can now add configuration documents to MongoDB and access it via the REST API.

1. Add configuration documents to MongoDB:

use config-db;

  "label": "master",
  "profile": "prod",
  "source": {
    "user": {
      "maxConnections": NumberInt(8),
      "timeoutMs": NumberInt(3600)

2. Access it by invoking http://localhost:8080/master/gateway-prod.properties:

user.maxConnections: 8
user.timeoutMs: 3600

Spring Cloud Config Client-backed components can be configured to automatically load configuration from MongoDB by leveraging Spring Cloud Config Server MongoDB. See here for an example!

Like it? Give the project a star on GitHub. You can also comment below. All feedback is welcome!