Skip to content
Go to file

Twitter Follow Documentation Examples Maven Central JavaDoc GitHub license Travis


cfg4j ("configuration for Java") is a configuration library for Java distributed apps (and more).


  • Open source
  • Easy to use
  • Auto-reloads configuration
  • Powerful configuration mechanisms (interface binding, multi-source support with fallback strategy, merging, ...)
  • Distributed-environment friendly ( caching, support for multiple environments [test, preprod, prod], ...)
  • Reads configuration from: Consul, Git repos (YAML and/or properties), Files, Classpath, ...
  • Modern design
    • Seamless integration with DI containers: Spring, Guice and others
    • Exposes performance metrics by integration with Metrics library
    • Extensible (see the list of plugins below)
    • Heavily tested (99% code coverage)
    • Well documented
    • Java 8+ required


Read an article about configuration management using cfg4j.

Detailed documentation

Head to the documentation.

Sample apps

Explore the code of the sample apps.

Quick start

Setting up dependency


dependencies {
  compile group: "org.cfg4j", name:"cfg4j-core", version: "4.4.1"
  // For Consul integration
  compile group: "org.cfg4j", name:"cfg4j-consul", version: "4.4.1"
  // For git integration
  compile group: "org.cfg4j", name:"cfg4j-git", version: "4.4.1"


  <!-- For Consul integration -->
  <!-- For git integration -->


The fastest way to start working with cfg4j is to use a Git repository as a configuration store. To do that follow the steps:

  • Use the following code in your application to connect to sample configuration source:
public class Cfg4jPoweredApplication {

  // Change this interface to whatever you want
  public interface SampleConfig {
    Integer birthYear();
    List<String> friends();
    URL homepage();
    Map<String, Character> grades();

  public static void main(String... args) {
    ConfigurationSource source = new GitConfigurationSourceBuilder()
    ConfigurationProvider provider = new ConfigurationProviderBuilder()
    SampleConfig config = configurationProvider.bind("reksio", SampleConfig.class);
    // Use it!

  • Optional steps
    1. Fork the configuration sample repository.
    2. Add your configuration to the "" file and commit the changes.
    3. Update the code above to point to your fork.


Licensed under the Apache License, Version 2.0. See LICENSE file.

You can’t perform that action at this time.