From d61a0d7430adbd919121437f34b93b05d2a56f85 Mon Sep 17 00:00:00 2001 From: Roberto Cortez Date: Thu, 4 Jul 2024 13:34:10 +0100 Subject: [PATCH] Support .env file by default (#1191) --- documentation/src/main/docs/config/getting-started.md | 7 ++++--- .../java/io/smallrye/config/SmallRyeConfigBuilder.java | 3 ++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/documentation/src/main/docs/config/getting-started.md b/documentation/src/main/docs/config/getting-started.md index b1b075b6a..1024e441e 100644 --- a/documentation/src/main/docs/config/getting-started.md +++ b/documentation/src/main/docs/config/getting-started.md @@ -6,9 +6,10 @@ By default, SmallRye Config reads configuration properties from multiple configu 1. (`400`) System properties 2. (`300`) Environment variables -3. (`260`) `application.properties` in `config` folder, located in the current working directory -3. (`250`) `application.properties` in the classpath -4. (`100`) MicroProfile Config configuration file `META-INF/microprofile-config.properties` in the classpath +3. (`295`) `.env` file in the current working directory +4. (`260`) `application.properties` in `config` folder, located in the current working directory +5. (`250`) `application.properties` in the classpath +6. (`100`) MicroProfile Config configuration file `META-INF/microprofile-config.properties` in the classpath A configuration source is handled by a `ConfigSource`. A `ConfigSource` provides configuration values from a specific place. diff --git a/implementation/src/main/java/io/smallrye/config/SmallRyeConfigBuilder.java b/implementation/src/main/java/io/smallrye/config/SmallRyeConfigBuilder.java index 33dc4e012..d75056dbf 100644 --- a/implementation/src/main/java/io/smallrye/config/SmallRyeConfigBuilder.java +++ b/implementation/src/main/java/io/smallrye/config/SmallRyeConfigBuilder.java @@ -203,8 +203,9 @@ protected List getDefaultSources() { protected List getSystemSources() { List sources = new ArrayList<>(); - sources.add(new EnvConfigSource()); sources.add(new SysPropConfigSource()); + sources.add(new EnvConfigSource()); + sources.addAll(new DotEnvConfigSourceProvider().getConfigSources(classLoader)); return sources; }