https://github.com/authme/configme
A simple configuration management library for any Java project!
https://github.com/authme/configme
config-management configme configuration configuration-management java properties properties-loader settings-storage yaml-configuration yaml-exporter
Last synced: 6 months ago
JSON representation
A simple configuration management library for any Java project!
- Host: GitHub
- URL: https://github.com/authme/configme
- Owner: AuthMe
- License: mit
- Created: 2016-07-08T13:30:30.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2025-03-17T05:27:20.000Z (7 months ago)
- Last Synced: 2025-03-30T21:07:02.521Z (6 months ago)
- Topics: config-management, configme, configuration, configuration-management, java, properties, properties-loader, settings-storage, yaml-configuration, yaml-exporter
- Language: Java
- Homepage:
- Size: 1.34 MB
- Stars: 37
- Watchers: 6
- Forks: 18
- Open Issues: 48
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# ConfigMe
[](https://github.com/AuthMe/ConfigMe/actions?query=branch%3Amaster)
[](https://coveralls.io/github/AuthMe/ConfigMe?branch=master)
[](https://www.javadoc.io/doc/ch.jalu/configme)
[](https://codeclimate.com/github/AuthMe/ConfigMe)A simple configuration management library with YAML support out of the box.
- Lightweight
- Flexible
- Out of the box support for YAML
- Allows migrations / config file checks
- Null-safe
- Unit testing friendly## How it works
- Each configurable value is a `Property` in ConfigMe. Properties are declared as `public static final` fields
in classes which implement the `SettingsHolder` interface.
- Configurations are read from a `PropertyResource` (e.g. the provided `YamlFileResource`), which abstracts reading
and writing.
- The _property resource_ may be checked for completeness with the `MigrationService`, which allows you also to rename
properties or to remove obsolete ones.
- The `SettingsManager` unifies the members above. On creation, it calls the migration service and allows you to get
and change property values.### Integration
Start using ConfigMe by adding this to your pom.xml:
```xml
ch.jalu
configme
1.4.1
```
### Example
**config.yml**
```yml
title:
text: 'Hello'
size: 12
```**TitleConfig.java**
```java
public class TitleConfig implements SettingsHolder {public static final Property TITLE_TEXT =
newProperty("title.text", "-Default-");public static final Property TITLE_SIZE =
newProperty("title.size", 10);private TitleConfig() {
// prevent instantiation
}
}
```**WelcomeWriter.java**
```java
public class WelcomeWriter {
public String generateWelcomeMessage() {
SettingsManager settings = SettingsManagerBuilder
.withYamlFile(Path.of("config.yml"))
.configurationData(TitleConfig.class)
.useDefaultMigrationService()
.create();// Get properties from the settings manager
return ""
+ settings.getProperty(TitleConfig.TITLE_TEXT) + "";
}
}
```
:pencil: Read the full documentation in the [ConfigMe Wiki](https://github.com/AuthMe/ConfigMe/wiki).:pencil: See a full working example based on this
[here](https://github.com/AuthMe/ConfigMe/tree/master/src/test/java/ch/jalu/configme/demo).:pencil: See how to use custom classes as property types in the
[bean properties demo](https://github.com/AuthMe/ConfigMe/tree/master/src/test/java/ch/jalu/configme/demo/beans).