Giter Site home page Giter Site logo

spring-cloud-config-server-mongodb's Introduction

spring-cloud-config-server-mongodb is no longer actively maintained by VMware, Inc.

Spring Cloud Config Server MongoDB

build-status Join the chat at https://gitter.im/spring-cloud-incubator/spring-cloud-config-server-mongodb

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

Quick Start

Configure pom.xml, like this:

<dependencies>
    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-config-server-mongodb</artifactId>
        <version>0.0.3.BUILD-SNAPSHOT</version>
    </dependency>
</dependencies>

<repositories>
    <repository>
        <id>spring-snapshots</id>
        <name>Spring Snapshots</name>
        <url>https://repo.spring.io/libs-snapshot-local</url>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </repository>
    <repository>
        <id>ojo-snapshots</id>
        <name>OJO Snapshots</name>
        <url>https://oss.jfrog.org/artifactory/libs-snapshot</url>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </repository>
</repositories>

Create a standard Spring Boot application, like this:

@SpringBootApplication
@EnableMongoConfigServer
public class Application {

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

}

Configure the application's spring.data.mongodb.* properties in application.yml, like this:

spring:
  data:
    mongodb:
      uri: mongodb://localhost/config-db

Add documents to the config-db mongo database, like this:

use config-db;

db.gateway.insert({
  "label": "master",
  "profile": "prod",
  "source": {
    "user": {
      "max-connections": 1,
      "timeout-ms": 3600
    }
  }
});

In the above snippet we've configured properties for an application named gateway having profile prod and label master.

The application-name is identified by the collection's name and a MongoDB document's profile and label values represent the Spring application's profile and label respectively. Note that documents with no profile or label values will have them considered default. All properties must be listed under the source key of the document.

Finally, access these properties by invoking http://localhost:8080/master/gateway-prod.properties. The response would be like this:

user.max-connections: 1.0
user.timeout-ms: 3600.0

References

spring-cloud-config

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.