An utility tool to handle .env files in Java.
<dependency>
<groupId>com.harium</groupId>
<artifactId>dotenv</artifactId>
<version>1.0.7</version>
</dependency>
Create a .env file and place it at the root folder of your project.
Get your variables using:
String myValue = Env.get("MY_SECRET");
Alternatively, you can use a custom path using the path parameter:
String myValue = Env.path("/home/user/myFolder").get("MY_SECRET");
If your variable is not declared in .env, dotenv will try to load it from the environment variables.
Dotenv looks for a .env file and loads it's contents. When you call
Env.get("MY_SECRET");
for the first time, dotenv will try to load all the variables and cache them.
At this repo you can find an example (.env) file: example.
Apache License 2.0