Dotenv relativer vs absoluter Pfad

werdas34

Bekanntes Mitglied
Hallo,

ich probiere grade bisschen mit env Dateien rum und nutze dafür Dotenv.

Java:
import io.github.cdimascio.dotenv.Dotenv;

Dotenv dotenv = Dotenv.configure()
                .directory("/src/main/resources")
                .filename("env")
                .load();

Soweit auch alles gut, aber wenn ich den relativen Pfad verwende erhalte ich eine Fehlermeldung. Mit dem absoluten Pfad funktioniert es einwandfrei. Woran liegt das?

Code:
Exception in thread "main" io.github.cdimascio.dotenv.DotEnvException: Could not find  rc/main/resources/env on the classpath
    at io.github.cdimascio.dotenv.internal.ClasspathHelper.loadFileFromClasspath(ClassPathHelper.kt:37)
    at io.github.cdimascio.dotenv.internal.DotenvReader.read(DotenvReader.kt:36)
    at io.github.cdimascio.dotenv.internal.DotenvParser.parse(DotenvParser.kt:26)
    at io.github.cdimascio.dotenv.DotenvBuilder.load(Dotenv.kt:111)
    at com.example.currency_spring.CurrencySpringApplication.main(CurrencySpringApplication.java:17)
    Suppressed: io.github.cdimascio.dotenv.DotEnvException: Could not find  rc\main\resources\env on the file system (working directory: C:\Users\Daniel\Desktop\currency_spring)
        at io.github.cdimascio.dotenv.internal.DotenvReader.read(DotenvReader.kt:40)
        ... 3 more

mfg werdas34
 
/src/main/resources ist ein absoluter Pfad, ein relativer waere src/main/resource oder ./src/main/resources.

Wobei der Pfad nur fuer deine Projekt-Umgebung gueltig ist, den wird es nicht geben wenn du die Applikation kompilierst.
 

Neue Themen


Zurück
Oben