Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/conf4j/conf4j
https://github.com/conf4j/conf4j
configuration consul etcd java
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/conf4j/conf4j
- Owner: conf4j
- License: apache-2.0
- Created: 2017-07-20T00:11:13.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-10-30T13:56:22.000Z (over 6 years ago)
- Last Synced: 2024-11-11T03:48:25.771Z (3 months ago)
- Topics: configuration, consul, etcd, java
- Language: Java
- Size: 167 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Configuration 4 Java
[![Build Status](https://travis-ci.org/conf4j/conf4j.svg?branch=master)](https://travis-ci.org/conf4j/conf4j)
[![Coverage Status](https://coveralls.io/repos/conf4j/conf4j/badge.svg?branch=master)](https://coveralls.io/r/conf4j/conf4j?branch=master)
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/org.conf4j/conf4j-core/badge.svg)](https://search.maven.org/#search%7Cga%7C1%7Cg%3A%22org.conf4j%22)## Installation
### Gradle
```groovy
compile 'org.conf4j:conf4j-core:2018.10.1'
```### Maven
```xml
org.conf4j
conf4j-core
2018.10.1```
## Usage
### Getting Started
1. Add `conf4j` dependency to your project
2. Build your configuration provider using `ConfigurationProviderBuilder`
3. Get an instance of your config bean from the configuration provider```java
public class Main {
public static void main(String[] args) throws Exception {
ConsulFileConfigurationSource prodConfigSource = ConsulFileConfigurationSource.builder()
.withConfigurationFilePath("prod/test-service.conf")
.withConsulUrl("localhost:8500")
.reloadOnChange()
.build();ClasspathConfigurationSource fallbackConfigSource = ClasspathConfigurationSource.builder()
.withResourcePath("fallback.conf")
.build();ConfigurationProvider provider = new ConfigurationProviderBuilder<>(TestConfigBean.class)
.withConfigurationSource(prodConfigSource)
.addFallback(fallbackConfigSource)
.build();provider.registerChangeListener((oldConfig, newConfig) -> myListener(newConfig));
TestConfigBean config = provider.get();
}
}
```### Contribution
- Fork
- Code
- ```./mvnw test```
- Issue a PR :)