paulschwarz/spring-dotenv

Unable to make it work

brainafesoh opened this issue ยท 5 comments

Hello, thanks for the initiative of creating this dependency. It's an issue I've been facing ever since I started working with springboot (since I come from a nodejs background)
However, I tried adding the dependency to a simple maven based project but wasn't able to make it work after all.

  • So here is a snippet of my application.yml file that contains the various project configs.
server:
   port: ${PIMPIM_REGISTRY_PORT:8761}
  • The content of the .env file is this: PIMPIM_REGISTRY_PORT=9999
  • And here, a snippet of my pom.xml file
<repositories>
  <repository>
    <snapshots>
      <enabled>false</enabled>
    </snapshots>
    <id>central</id>
    <name>bintray</name>
    <url>https://jcenter.bintray.com</url>
  </repository>
</repositories>
<dependencies>
  <dependency>
    <groupId>me.paulschwarz</groupId>
    <artifactId>spring-dotenv</artifactId>
    <version>1.0.0</version>
    <type>pom</type>
  </dependency>
</dependencies>

However when I run the project, my server still starts on default port 8761 rather than 9999 as precised in the .env file
image

Along with this message that make me feel like there's something not done right.
image

Thanks for any help!!

@brainafesoh please try remove the <type>pom</type> from your dependency block and try again?

@brainafesoh also, your application.yml should read

server:
   port: ${env.PIMPIM_REGISTRY_PORT:8761}

(note the env.)

I haven't heard from you recently and I hope this solved your issue. Please reopen if not.

Also had this issue. This solved beautifully after struggling a bit to setup bintray.