paulschwarz/spring-dotenv

Demo app doesn't seem to work

aBnormaLz opened this issue · 3 comments

I downloaded the demo application, imported it into IntelliJ, then. copied the .env.example file to .env file with the following content

# Copy this file to .env and fill in your values

# The name used by our "hello world" application
EXAMPLE_NAME=Something

When I send a GET request to localhost:8080 it responds with Hello, World instead of Hello, Something. What did I miss?

Sorry to hear that.

I verified it and it's working for me, so may I ask you to push up a repo so I can clone and see exactly what you're seeing?

Also, are you using Gradle or Maven? and which version are you using?

Actually I got it working in my project, the problem was the same as in this issue #2. I removed the type>pom</type> from the pom.xml and it is now working so this is great!

Maybe an update to the README would be nice since if you take a look at the bintray link in the README https://bintray.com/paulschwarz/maven/spring-dotenv it contains that type thingy.

Anyways I didn't really modify anything in the example code, just cloned it, created the .env in the application folder and tried to run it in IntelliJ with the debug mode. It seems that the DotenvPropertySource doesn't get called. I tried to set the log level but I either I failed or there is no log from that class.

It gives back the World default value correctly, but I cannot overwrite it from the .env file. If I remove the default value the application couldn't start because it Could not resolve placeholder 'env.EXAMPLE_NAME' in value "${env.EXAMPLE_NAME}"

Can you please try to run it with IntelliJ? :)

Sorry for the late response @aBnormaLz , I wonder what's going on here.

To test it out from scratch, I started a brand new application using https://start.spring.io/ and I chose Maven Project.

I then added the spring-dotenv library to the dependencies using these instructions https://github.com/paulschwarz/spring-dotenv/releases/latest

I set up a very simple Spring Boot app that simply prints out a value coming from application.properties

In src/main/resources/application.properties I have example.name = ${env.EXAMPLE_NAME}
In src/main/resources/.env I have EXAMPLE_NAME=World

And that's all there is to it.