Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/cfg4j/cfg4j
Modern configuration library for distributed apps written in Java.
https://github.com/cfg4j/cfg4j
Last synced: 4 months ago
JSON representation
Modern configuration library for distributed apps written in Java.
- Host: GitHub
- URL: https://github.com/cfg4j/cfg4j
- Owner: cfg4j
- License: apache-2.0
- Created: 2015-05-20T01:14:19.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2022-07-14T13:19:32.000Z (over 2 years ago)
- Last Synced: 2024-08-01T18:24:28.798Z (7 months ago)
- Language: Java
- Homepage: http://cfg4j.org
- Size: 979 KB
- Stars: 555
- Watchers: 26
- Forks: 116
- Open Issues: 95
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-java - cfg4j - Modern configuration library for distributed apps written in Java. (Projects / Configuration)
README
[](https://twitter.com/norbert_potocki)
[](http://cfg4j.org)
[](https://github.com/cfg4j/cfg4j-sample-apps)
[](http://search.maven.org/#search|ga|1|org.cfg4j.cfg4j-core)
[](http://www.javadoc.io/doc/org.cfg4j/cfg4j-core)
[](https://github.com/cfg4j/cfg4j/blob/master/LICENSE)
[](https://travis-ci.org/cfg4j/cfg4j)# Overview
**cfg4j** ("configuration for Java") is a **configuration library for Java distributed apps** (and more).
#### Features:
* 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](https://github.com/cfg4j/cfg4j-sample-apps/tree/master/consul-bind),
[Git repos (YAML and/or properties)](https://github.com/cfg4j/cfg4j-sample-apps/tree/master/git-bind),
[Files](https://github.com/cfg4j/cfg4j-sample-apps/tree/master/files-bind),
[Classpath](https://github.com/cfg4j/cfg4j-sample-apps/tree/master/classpath-bind), ...**
* Modern design
* Seamless integration with DI containers: **[Spring](https://spring.io/)**, **[Guice](https://github.com/google/guice)** and others
* Exposes performance metrics by integration with **[Metrics library](http://metrics.dropwizard.io)**
* Extensible (see the list of **plugins** below)
* Heavily tested (**99% code coverage**)
* Well [documented](http://cfg4j.org)
* Java 8+ required# Usage
Read [an article about configuration management using cfg4j](http://potocki.io/post/141230472743/configuration-management-for-distributed-systems).## Detailed documentation
Head to [the documentation](http://cfg4j.org).## Sample apps
Explore the code of the [sample apps](https://github.com/cfg4j/cfg4j-sample-apps).## Quick start
### Setting up dependency
#### Gradle
```groovy
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"
}
```#### Maven
```xml
org.cfg4j
cfg4j-core
4.4.1
org.cfg4j
cfg4j-consul
4.4.1
org.cfg4j
cfg4j-git
4.4.1
```
### Usage
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:
```java
public class Cfg4jPoweredApplication {// Change this interface to whatever you want
public interface SampleConfig {
Integer birthYear();
List friends();
URL homepage();
Map grades();
}public static void main(String... args) {
ConfigurationSource source = new GitConfigurationSourceBuilder()
.withRepositoryURI("https://github.com/cfg4j/cfg4j-git-sample-config.git")
.build();
ConfigurationProvider provider = new ConfigurationProviderBuilder()
.withConfigurationSource(source)
.build();
SampleConfig config = configurationProvider.bind("reksio", SampleConfig.class);
// Use it!
System.out.println(config.homepage());
}}
```* Optional steps
1. Fork the [configuration sample repository](https://github.com/cfg4j/cfg4j-git-sample-config).
2. Add your configuration to the "*application.properties*" file and commit the changes.
3. Update the code above to point to your fork.
# License
Licensed under the Apache License, Version 2.0. See LICENSE file.