Skip to content

lserveriiev/configuration

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Configuration parser and reader

License: MIT Build Status

Parse and read configurations in java. This package covers only parsing the configuration properties files and resolving the environment variables in these files.

Install

This package didn't upload to the maven central repository. Thus, for using this dependency you can use Jitpack.io.

1. Add the Jitpack repository to pom.xml

<repositories>
    <repository>
        <id>jitpack.io</id>
        <url>https://jitpack.io</url>
    </repository>
</repositories>

2. Add the di dependency to pom.xml

<dependency>
    <groupId>com.github.serveriev</groupId>
    <artifactId>configuration</artifactId>
    <version>v1.0</version>
</dependency>

How to use

1. Add a configuration file to the resource folder.

2. Load and read configuration.

import io.lenur.configuration.Configuration;

public class Application {

    public static void main(String[] args) {
        Configuration configuration = new Configuration("application.properties");
        System.out.println(configuration.get("database.username"));
        System.out.println(configuration.get("database.url"));
        String[] tech = configuration.getAsStringArray("technology.stack");//returns an array splitted by regex. default delimiter is | 
        String[] tech1 = configuration.getAsStringArray("technology.stack.regex", ",");//pass own delimiter
    }
}

Issues

✅ Parsing property files

❌ Parsing yaml files

❌ Parsing xml file

✅ Resolving environment variables

❌ Resolving system variables

Author

Lenur

License

Copyright © 2020 Lenur.

This project is MIT licensed.

About

Parsing and using configuration in java

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published