Giter Club home page Giter Club logo

springify-multiconfig's Introduction

Springify Multiconfig Build Status Maven Central Licence

Springify Multiconfig loads application YAML files from all jars in the classpath into the application context of a Spring Boot application, helping to split the configuration of multi-module projects.

It’s part of Springify, a set of open source libraries supporting the development of Spring Boot projects.

Usage

Just add the dependency from the Maven Central Repository:

<dependency>
  <groupId>com.it-surmann</groupId>
  <artifactId>springify-multiconfig</artifactId>
  <version>1.0.0</version>
</dependency>

Springify Multiconfig is now scanning for files with the name application-mc-*.yml, which are then loaded into the application context.

Example

A typical multi-module project may look like this.

 +-------------------+
 |    module-web     | containing application.yml, application-prod.yml
 +-------------------+
          |
          V
 +-------------------+
 |    module-blog    | containing application-mc-blog.yml
 +-------------------+
          |
          V
 +-------------------+
 | module-newsletter |  containing application-mc-newsletter.yml
 +-------------------+
          |
          V
 +-------------------+
 |   module-basics   | containing application-mc-basics.yml
 +-------------------+

The separation helps to keep code and configuration together, so each module can provide its own configuration if needed. The default behaviour for initializing the application context remains untouched, so in the example the application YAML files of module-web are loaded by Spring Boot itself (depending on the active profile).

Tip
Specify the dependency to springify-multiconfig on the lowest module (module-basics).

When the application is started, all modules are part of it and all application YAML files are loaded. They are ordered corresponding to the dependency graph, so in the example the application-mc-blog.yml would override properties of application-mc-newsletter.yml and application-mc-basics.yml with the same name (if present).

If a module contains a test class initializing the context, only the application YAML files of the current module plus dependencies are loaded. For example a class NewsletterServiceIT in module-newsletter annotated with @SpringBootTest would load application-mc-basics.yml as well as application-mc-newsletter.yml, but nothing else.

springify-multiconfig's People

Contributors

tleipzig avatar

Watchers

James Cloos avatar

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.