Comments (8)
Ahh I see. That's totally fixed. I included the resources
folder under src/main
instead of in the root of the project.
from dotenv-kotlin.
@jessevdp, this is the correct behavior. The two paths are different locations.
The first, ./
is a relative path, thus Dotenv
will search with respect to the current working directory
The second, /
is an absolute path, thus Dotenv
will search the root of your filesystem for .env
Note if there are no matches, Dotenv
will then search the java classpath. It's common that this be the resources
directory particularly if you're using the maven project structure
from dotenv-kotlin.
@jessevdp this stuff gets a bit tricky, but ultimately, you need to know the directory from which java
is executed from. It determines the point from which relative paths are resolved e.g. ./
You're IDE may also set this directory. If possible, it may be worth executing your app from the command line to be absolutely sure which directory you are running from
Let me know if i can help in anyway, I definitely want to get this working for you
from dotenv-kotlin.
These examples may help
Spring: .env
is pulled from the classpath. It is stored in resources
directory:
https://github.com/cdimascio/kotlin-swagger-spring-functional-template/tree/master/src/main/resources
There is an Android example in the README as well, if needed
from dotenv-kotlin.
I am using maven. I did just try to make a resource
directory and put the .env
file in there and I removed all the configuration. This still gave me the same error.
I am using Eclipse so there's a slight chance that just adding the folder didn't have the desired effect. I know there's a .classpath
file. I'm just not very used to what it does or how to use it. By default it's excluded from source control as well.
I come from the world of Node.js
where everyone has to compile and execute their apps from the command line. These concepts are kind of foreign to me.
That link is broken, should remove the back-tick.
The first, ./ is a relative path, thus Dotenv will search with respect to the current working directory
The second, / is an absolute path, thus Dotenv will search the root of your filesystem for .env.
Oeps, that's true. Guess it was in too having a bit of tunnel vision yesterday 😂
from dotenv-kotlin.
@jessevdp here is a super basic example of a Maven project using dotenv where .env
lives in the the resources
directory
https://github.com/cdimascio/java-dotenv-example
Be sure to set up the directory structure as shown in this example. It aligns with the standard Maven structure.
The example has instructions to run on the command line. Once, you see that work, try from eclipse
from dotenv-kotlin.
Here is a direct link to the actual code (you'll find it is very simple):
And a link to the .env
file
https://github.com/cdimascio/java-dotenv-example/blob/master/src/main/resources/.env
And the pom.xml
file
https://github.com/cdimascio/java-dotenv-example/blob/master/pom.xml
Again, the project is set up using the Maven structure. Assuming you set your project up similarly (which is recommended even if not using java-dotenv
), it should work
from dotenv-kotlin.
Excellent! I added the example to the README
. closing this out
from dotenv-kotlin.
Related Issues (20)
- Dotenv entries() result is not overridden by environment variables HOT 3
- Not working correctly when I execute a jar after gradle build HOT 2
- Option to only load .env file env vars HOT 6
- Multiline value HOT 8
- using env vars from host, it requires .env file HOT 1
- Directory configuration not working correctly HOT 3
- question - incorporating into build.gradle HOT 5
- 5.1.3 library version does not resolve correctly .env file location in jar file. HOT 3
- How is it different from Spring properties? HOT 5
- Make dotenv env variables available in System.getProperty() too HOT 6
- .env file and Travis HOT 5
- Getting an error when running a jar that uses dotenv HOT 1
- kotlin libs are required HOT 3
- Update version in readme
- Crashes on Android version 7 and older HOT 2
- package version 6.3.0 is not published anywhere other than github packages HOT 1
- Android Could not find /asset/env on the classpath HOT 1
- Errors when attempting to start it from a jar.
- Latest build on maven HOT 1
- Feature missing in docs.. DECLARED_IN_ENV filter
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dotenv-kotlin.