{"id":45279541,"url":"https://github.com/paulschwarz/spring-dotenv","last_synced_at":"2026-02-21T02:24:41.698Z","repository":{"id":39710691,"uuid":"242444304","full_name":"paulschwarz/spring-dotenv","owner":"paulschwarz","description":"Provides a Dotenv property source for Spring and Spring Boot","archived":false,"fork":false,"pushed_at":"2026-01-02T07:04:10.000Z","size":328,"stargazers_count":440,"open_issues_count":11,"forks_count":31,"subscribers_count":6,"default_branch":"main","last_synced_at":"2026-01-08T00:21:51.007Z","etag":null,"topics":["config","dotenv","environment-variables","java","spring","springboot"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/paulschwarz.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2020-02-23T02:35:03.000Z","updated_at":"2026-01-05T02:08:18.000Z","dependencies_parsed_at":"2023-02-17T03:30:51.545Z","dependency_job_id":null,"html_url":"https://github.com/paulschwarz/spring-dotenv","commit_stats":null,"previous_names":[],"tags_count":29,"template":false,"template_full_name":null,"purl":"pkg:github/paulschwarz/spring-dotenv","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paulschwarz%2Fspring-dotenv","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paulschwarz%2Fspring-dotenv/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paulschwarz%2Fspring-dotenv/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paulschwarz%2Fspring-dotenv/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/paulschwarz","download_url":"https://codeload.github.com/paulschwarz/spring-dotenv/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paulschwarz%2Fspring-dotenv/sbom","scorecard":{"id":723601,"data":{"date":"2025-08-11","repo":{"name":"github.com/paulschwarz/spring-dotenv","commit":"5b8cb3b8e5bc73b43bc47e2c27159078cbd1c252"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.5,"checks":[{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/cd.yml:1","Warn: no topLevel permission defined: .github/workflows/ci.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Code-Review","score":2,"reason":"Found 5/18 approved changesets -- score normalized to 2","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Binary-Artifacts","score":9,"reason":"binaries present in source code","details":["Warn: binary detected: gradle/wrapper/gradle-wrapper.jar:1"],"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/cd.yml:12: update your workflow using https://app.stepsecurity.io/secureworkflow/paulschwarz/spring-dotenv/cd.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/cd.yml:19: update your workflow using https://app.stepsecurity.io/secureworkflow/paulschwarz/spring-dotenv/cd.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/cd.yml:32: update your workflow using https://app.stepsecurity.io/secureworkflow/paulschwarz/spring-dotenv/cd.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:17: update your workflow using https://app.stepsecurity.io/secureworkflow/paulschwarz/spring-dotenv/ci.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:22: update your workflow using https://app.stepsecurity.io/secureworkflow/paulschwarz/spring-dotenv/ci.yml/master?enable=pin","Info:   0 out of   5 GitHub-owned GitHubAction dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 18 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-22T12:07:16.590Z","repository_id":39710691,"created_at":"2025-08-22T12:07:16.591Z","updated_at":"2025-08-22T12:07:16.591Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29671572,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-21T00:11:43.526Z","status":"online","status_checked_at":"2026-02-21T02:00:07.432Z","response_time":107,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["config","dotenv","environment-variables","java","spring","springboot"],"created_at":"2026-02-21T02:24:41.096Z","updated_at":"2026-02-21T02:24:41.681Z","avatar_url":"https://github.com/paulschwarz.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🌱🔐 Spring-Dotenv\n\n[![CI](https://github.com/paulschwarz/spring-dotenv/actions/workflows/ci.yml/badge.svg)](https://github.com/paulschwarz/spring-dotenv/actions/workflows/ci.yml)\n[![Release](https://github.com/paulschwarz/spring-dotenv/actions/workflows/release.yml/badge.svg)](https://github.com/paulschwarz/spring-dotenv/actions/workflows/release.yml)\n\n[![Maven Central](https://img.shields.io/maven-central/v/me.paulschwarz/spring-dotenv?label=spring-dotenv)](https://search.maven.org/artifact/me.paulschwarz/spring-dotenv)\n[![Maven Central](https://img.shields.io/maven-central/v/me.paulschwarz/springboot3-dotenv?label=springboot3-dotenv)](https://search.maven.org/artifact/me.paulschwarz/springboot3-dotenv)\n[![Maven Central](https://img.shields.io/maven-central/v/me.paulschwarz/springboot4-dotenv?label=springboot4-dotenv)](https://search.maven.org/artifact/me.paulschwarz/springboot4-dotenv)\n\n[![GitHub](https://img.shields.io/github/license/paulschwarz/spring-dotenv)](https://github.com/paulschwarz/spring-dotenv/blob/main/LICENSE)\n[![GitHub stars](https://img.shields.io/github/stars/paulschwarz/spring-dotenv)](https://github.com/paulschwarz/spring-dotenv/stargazers)\n\n---\n\n## What this library does\n\n**Spring-Dotenv** integrates the excellent\n[dotenv-java](https://github.com/cdimascio/dotenv-java) library into the Spring\necosystem by exposing `.env` files as a Spring\n[`PropertySource`](https://docs.spring.io/spring-framework/reference/core/beans/environment.html).\n\nIt lets you:\n\n- Load environment variables from a local `.env` file during development\n- Keep production behavior unchanged (real environment variables always win because `.env` values are added after system environment variables, preserving standard Spring precedence)\n- Follow [The Twelve-Factor App](https://12factor.net/config) principle of *configuration via environment*\n\nThe `.env` file is strictly a **development convenience**. It should never be\ncommitted to source control.\n\n📄 See the [CHANGELOG.md](CHANGELOG.md) for breaking changes, upgrades, and release notes.\n\n---\n\n## Requirements\n\n- **Java 17 or newer**\n- Spring Framework or Spring Boot 3 / 4\n\nIf you need Java 8 or 11 support, use an older release.\n\n---\n\n## Modules\n\nThis project is published as multiple artifacts. Choose **exactly one** at runtime.\n\n- **`spring-dotenv`**  \n  Core library for Spring Framework (no Spring Boot auto-integration)\n\n- **`springboot3-dotenv`**  \n  Auto-integrates with Spring Boot 3\n\n- **`springboot4-dotenv`**  \n  Auto-integrates with Spring Boot 4\n\nA BOM is provided to keep versions aligned across modules.\n\n---\n\n## Installation\n\n### Recommended (BOM-based)\n\n#### Gradle\n\n```kotlin\ndependencies {\n    implementation(platform(\"me.paulschwarz:spring-dotenv-bom:$version\"))\n    developmentOnly(\"me.paulschwarz:springboot4-dotenv\")\n}\n```\n\n#### Maven\n\n```xml\n\u003cdependencyManagement\u003e\n    \u003cdependencies\u003e\n        \u003cdependency\u003e\n            \u003cgroupId\u003eme.paulschwarz\u003c/groupId\u003e\n            \u003cartifactId\u003espring-dotenv-bom\u003c/artifactId\u003e\n            \u003cversion\u003e$version\u003c/version\u003e\n            \u003ctype\u003epom\u003c/type\u003e\n            \u003cscope\u003eimport\u003c/scope\u003e\n        \u003c/dependency\u003e\n    \u003c/dependencies\u003e\n\u003c/dependencyManagement\u003e\n\n\u003cdependencies\u003e\n    \u003cdependency\u003e\n        \u003cgroupId\u003eme.paulschwarz\u003c/groupId\u003e\n        \u003cartifactId\u003espringboot4-dotenv\u003c/artifactId\u003e\n        \u003coptional\u003etrue\u003c/optional\u003e\n    \u003c/dependency\u003e\n\u003c/dependencies\u003e\n```\n\n## First-time set up\n\nAdd `.env` to your `.gitignore`:\n\n```gitignore\n.env\n```\n\nIt’s common to commit a `.env.example` file instead, documenting the available\nvariables without leaking secrets.\n\n---\n\n## Usage\n\nAssume a simple Spring application that needs a configurable value:\n\n```java\n\n@Value(\"${example.name}\")\nString name;\n```\n\nDeclare the property in `application.yml`:\n\n```yaml\nexample:\n  name: ${EXAMPLE_NAME:World}\n```\n\nCreate a local `.env` file:\n\n```dotenv\nEXAMPLE_NAME=Paul\n```\n\nAt runtime:\n\n- If `EXAMPLE_NAME` is set in the real environment, **that value wins**\n- Otherwise, the value from `.env` is used\n- If neither is present, the default (`World`) applies\n\nThis preserves production safety while making local development frictionless.\n\nKeys loaded from `.env` participate in relaxed name resolution **when running under Spring Boot (3 or 4)**.\nIn plain Spring Framework applications, `.env` keys are resolved **strictly**.\n\nFor example, under Spring Boot:\n\n```dotenv\nMY_SERVICE_URL=https://example.com\n```\n\ncan be accessed as:\n\n```properties\nmy.service.url\n```\n\n---\n\n## Configuration (optional)\n\nAll configuration is optional. Defaults are sensible.\n\n### Spring Framework vs Spring Boot\n\n- **Spring Boot 3 / 4**\n  - Relaxed binding is applied to:\n    - `springdotenv.*` configuration keys\n    - variables defined inside `.env` files\n  - Standard Spring Boot rules apply (kebab-case, camelCase, uppercase environment variables).\n\n- **Plain Spring Framework**\n  - Configuration is **strict**:\n    - `springdotenv.*` keys must match exactly\n    - `.env` entries must match exactly\n  - No relaxed binding is applied.\n\n| System property                         | Environment variable                       | Default value |\n|-----------------------------------------|--------------------------------------------|---------------|\n| `springdotenv.enabled`                  | `SPRINGDOTENV_ENABLED`                     | `true`        |\n| `springdotenv.directory`                | `SPRINGDOTENV_DIRECTORY`                   |               |\n| `springdotenv.filename`                 | `SPRINGDOTENV_FILENAME`                    | `.env`        |\n| `springdotenv.ignoreIfMalformed`        | `SPRINGDOTENV_IGNORE_IF_MALFORMED`         | `false`       |\n| `springdotenv.ignoreIfMissing`          | `SPRINGDOTENV_IGNORE_IF_MISSING`           | `true`        |\n| `springdotenv.exportToSystemProperties` | `SPRINGDOTENV_EXPORT_TO_SYSTEM_PROPERTIES` | `false`       |\n\n⚠️ **Binding semantics note**  \nThe keys shown above support relaxed binding **only in Spring Boot applications**.  \nWhen using the core `spring-dotenv` module without Spring Boot, these keys must be specified exactly.\n\n### Notable options\n\n- `springdotenv.enabled`  \n  Defaults to `true`. Set to `false` to completely disable integration.\n\n- `springdotenv.exportToSystemProperties`  \n  If enabled, variables loaded from `.env` are also exported to `System.getProperties()`.  \n  This field was previously known as `systemProperties` but was renamed for clarity. \n  It is deprecated but still supported with warning.  \n  If both the legacy and the canonical property are set, the canonical key (`springdotenv.exportToSystemProperties`) takes precedence.  \n  When `exportToSystemProperties` is enabled, `.env` variables are exported verbatim. Relaxed name resolution is applied only when values are read via Spring’s Environment.\n\n- `springdotenv.ignoreIfMissing`  \n  Defaults to `true`. Set to `false` to fail fast when `.env` is absent.\n\n---\n\n### Notes on prefixes\n\nOlder versions required properties to be prefixed (for example `env.EXAMPLE_NAME`).\n\nThis is no longer the case. Prefixes have been removed.\n\n---\n\n### Configuration binding semantics\n\nSpring-Dotenv follows the configuration rules of the runtime it integrates with.\n\n#### Spring Boot applications\n\nWhen used with **Spring Boot 3 or 4**, all `springdotenv.*` configuration options **and `.env` file entries** participate in **standard Spring Boot relaxed binding**.\n\nThis means configuration keys are interchangeable across common naming styles:\n\n- `springdotenv.ignore-if-missing` \n- `springdotenv.ignoreIfMissing` \n- `SPRINGDOTENV_IGNORE_IF_MISSING`\n\nLikewise, variables defined in `.env` files are resolved using the same relaxed rules when accessed through the Spring `Environment`. For example:\n\n```dotenv\nMY_SERVICE_URL=https://example.com\n```\n\ncan be consumed as:\n\n```properties\nmy.service.url\n```\n\nThis behavior is delegated to Spring Boot’s native `Binder` and matches Boot’s built-in configuration semantics.\n\n#### Spring Framework (non-Boot) applications\n\nWhen using the **core** `spring-dotenv` **module without Spring Boot**, all configuration is **strict**:\n\n- `springdotenv.*` keys must match exactly  \n- `.env` entries are resolved by exact name only  \n- No relaxed binding or env-var style name conversion is applied\n\nThis distinction is intentional and mirrors the behavior of Spring Framework itself.\n\n---\n\n## Building locally\n\n```shell\n./gradlew build\n```\n\n---\n\n## Contributing\n\nPull requests are welcome.\n\nFor substantial changes, please open an issue first to discuss scope and approach.\nTests are expected for behavioral changes.\n\n---\n\n## License\n\nMIT © Paul Schwarz\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpaulschwarz%2Fspring-dotenv","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpaulschwarz%2Fspring-dotenv","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpaulschwarz%2Fspring-dotenv/lists"}