The UI of Run/Debug Configurations has changed. Under 'Modify Options' select 'Environment Variables' under 'Operating System'.

JetBrains
jetbrains.com › help › idea › program-arguments-and-environment-variables.html
Program arguments, VM options, environment variables | IntelliJ IDEA Documentation
May 27, 2025 - For configuration through an .env file or a script – enter the path to the file or use the Browse for .env files and scripts button in the Environment variables field. In the case of multiple files, separate them with semicolons (;). This is the most common location of the option, which corresponds to run configurations such as Application, Maven, or Spring Boot.
java - environment variable used with gradle intellij - spring boot - Stack Overflow
I am building a Spring Boot Java application using the lattest version of IntelliJ built with gradle on Windows 7. I am trying to leverage environment variables in my application.properties, one w... More on stackoverflow.com
How do I activate a Spring Boot profile when running from IntelliJ? - Stack Overflow
So now when running bootRun from IntelliJ, it defaults to the "local" profile. On our other environments, we will simply set the 'SPRING_PROFILES_ACTIVE' environment variable in Tomcat. More on stackoverflow.com
How do you use env files or deal with environment variables in Spring Boot?
Please ensure that: Your code is properly formatted as code block - see the sidebar (About on mobile) for instructions You include any and all error messages in full - best also formatted as code block You ask clear questions You demonstrate effort in solving your question/problem - plain posting your assignments is forbidden (and such posts will be removed) as is asking for or giving solutions. If any of the above points is not met, your post can and will be removed without further warning. Code is to be formatted as code block (old reddit/markdown editor: empty line before the code, each code line indented by 4 spaces, new reddit: https://i.imgur.com/EJ7tqek.png ) or linked via an external code hoster, like pastebin.com, github gist, github, bitbucket, gitlab, etc. Please, do not use triple backticks (```) as they will only render properly on new reddit, not on old reddit. Code blocks look like this: public class HelloWorld { public static void main(String[] args) { System.out.println("Hello World!"); } } You do not need to repost unless your post has been removed by a moderator. Just use the edit function of reddit to make sure your post complies with the above. If your post has remained in violation of these rules for a prolonged period of time (at least an hour), a moderator may remove it at their discretion. In this case, they will comment with an explanation on why it has been removed, and you will be required to resubmit the entire post following the proper procedures. To potential helpers Please, do not help if any of the above points are not met, rather report the post. We are trying to improve the quality of posts here. In helping people who can't be bothered to comply with the above points, you are doing the community a disservice. I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns. More on reddit.com
Best to handle environment variables
You can set properties using environment variables, e.g. setting environment variable SPRING_DATASOURCE_PASSWORD will set property spring.datasource.password automatically without it mentioned in a configuration file. You don't put secrets in your configuration files, you put that in your environment somehow, e.g. in Kubernetes secrets or whatever your environment is. More on reddit.com
Videos
16:31
Spring Boot Environment Variables Explained (Secure Your API Keys!)
Manejo Variables de entorno en Springboot y IntelliJ IDEA
10:22
Environment Variables in Spring Boot Properties: Override default ...
08:15
How to Configure and Create Spring Boot Project in IntelliJ IDEA ...
JetBrains
intellij-support.jetbrains.com › hc › en-us › community › posts › 10751186096146-Environment-variables-in-Spring-Boot-run-configuration-aren-t-available-to-Gradle-during-build
Environment variables in Spring Boot run configuration aren't available to Gradle during build – IDEs Support (IntelliJ Platform) | JetBrains
March 28, 2023 - Your Gradle build will see the environment only if you run Gradle configuration from IntelliJ IDEA. ... Thanks for the response. If I'm understanding right, it sounds like an intentional design decision to not set the environment variables from a run configuration before the build happens? Also, you said that Spring Boot and Application configurations should not set the environment before the build, however Application DOES set the environment variable from the run configuration.
YouTube
youtube.com › watch
How To Set Environment Variables in Your Spring Boot Application | Read the variable | IntelliJ IDEA - YouTube
In this tutorial, you will learn how to set environment variable Spring Boot application, and also use the variable in the application.yml or application.pro...
Published October 18, 2023
JetBrains
intellij-support.jetbrains.com › hc › en-us › community › posts › 360009631260-Environment-variable-mapped-to-spring-boot-configuration-property-but-in-my-infra-Kubernetes-Cluster-the-environment-variable-not-mapped-to-spring-boot-configuration
Environment variable mapped to spring boot configuration property but in my infra(Kubernetes Cluster), the environment variable not mapped to spring boot configuration – IDEs Support (IntelliJ Platform) | JetBrains
August 28, 2020 - Change in deployment.yaml shown below: env: - name: CLIENT_CLIENTID_ENG-USA value: "abc123" Then the environment variable is created inside the container but its not mapped to corresponding spring boot config variable.
CodingTechRoom
codingtechroom.com › question › how-to-add-environment-variables-in-your-intellij-spring-boot-project
How to Add Environment Variables in a Spring Boot Project Using IntelliJ IDEA - CodingTechRoom
// Example of defining an environment ... variables can help manage sensitive information such as API keys, database passwords, etc. Open your Spring Boot project in IntelliJ IDEA....
JetBrains
intellij-support.jetbrains.com › hc › en-us › community › posts › 20540208284434-Intellij-Spring-boot-isn-t-able-to-pass-environments-variables-when-I-made-run-Macbook-Apple-silicon
Intellij (Spring boot) isn't able to pass environments variables when I made run (Macbook Apple silicon). – IDEs Support (IntelliJ Platform) | JetBrains
* What went wrong: Execution failed for task ':edge-operator-mobile-service:bootRun'. > Process 'command '/Library/Java/JavaVirtualMachines/jdk-1.8.jdk/Contents/Home/bin/java'' finished with non-zero exit value 1. I tried to set the environment variable in application.properties the error was gone but a new error occurred.
CodingTechRoom
codingtechroom.com › question › -set-environment-variable-spring-boot-gradle-intellij
How to Set Environment Variables in Spring Boot Using Gradle and IntelliJ - CodingTechRoom
To set environment variables in Gradle, you can modify the build.gradle file and configure the 'bootRun' task to include the necessary environment variables. For IntelliJ IDEA, ensure that you configure the environment variables in the Run/Debug configurations, which is accessible from the top right corner of the IDE.
Medium
medium.com › @aqilzeka99 › how-to-work-productively-with-environment-variables-in-spring-boot-86af52b68dc8
How to Work Productively with Environment Variables in Spring Boot | by Agil | Medium
April 23, 2025 - To set environment variables: ... Now your variables are available in every terminal session. 6. You can see it in the terminal with bthe elow command: ... Let’s say you’re building a Spring Boot app. Instead of hardcoding credentials, configure your application.yml like this: spring: datasource: url: jdbc:postgresql://localhost:5432/mydb username: user password: ${DB_PASSWORD_DEV} If IntelliJ doesn’t automatically pick up your environment variables invalidate and restart your IntelliJ.
JetBrains
intellij-support.jetbrains.com › hc › en-us › community › posts › 10075122899986-How-to-use-env-or-envrc-files-to-pull-env-vars-for-run-debug-configurations
How to use .env or .envrc files to pull env vars for run/debug configurations? – IDEs Support (IntelliJ Platform) | JetBrains
February 13, 2023 - If you are working with Spring and IntelliJ. You should try without plugins to add this environment entry spring.config.import=optional:file:D:/IdeaProjects/[YOUR-PROJECT-HERE]/.env[.properties] .env[.properties] tells Spring Boot that .env should be treated as a properties file.
Stack Overflow
stackoverflow.com › questions › 47357761 › environment-variable-used-with-gradle-intellij-spring-boot
java - environment variable used with gradle intellij - spring boot - Stack Overflow
November 18, 2017 - setEnvVarRunConfiguration 'MyApplication', 'LOG_LEVEL', 'INFO' def setEnvVarRunConfiguration( final String configuration, final String envName, final String envValue ) { final javaExecRunConfiguration = { task -> task instanceof JavaExec && task.name == "run $configuration" } tasks.matching(javaExecRunConfiguration).all { environment envName, envValue } }
JetBrains
intellij-support.jetbrains.com › hc › en-us › community › posts › 5818950617618-Is-there-any-good-way-to-use-env-file-in-bootrun
Is there any good way to use .env file in bootrun? – IDEs Support (IntelliJ Platform) | JetBrains
May 29, 2022 - We can run the spring boot project from the buttons at top-right corner. Is there any good way to use ".env" file in the project? We can configure environmental variables one-by-one in the Run/Debug configuration dialog, but it would be better if I could use ".env" file.
JetBrains
youtrack.jetbrains.com › issue › IDEA-188768 › Environment-variables-set-in-run-configuration-not-set
Environment variables set in run configuration not set
{{ (>_<) }} This version of your browser is not supported. Try upgrading to the latest stable version. Something went seriously wrong
JetBrains
youtrack.jetbrains.com › issue › IDEA-341647 › Copy-a-Spring-Boot-properties-file-variable-as-an-environment-variable
Copy a Spring Boot properties file variable as an ...
{{ (>_<) }} This version of your browser is not supported. Try upgrading to the latest stable version. Something went seriously wrong
Top answer 1 of 16
495
I added -Dspring.profiles.active=test to VM Options and then re-ran that configuration. It worked perfectly.
This can be set by
- Choosing
Run | Edit Configurations... - Go to the
Configurationtab - Expand the
Environmentsection to revealVM options
2 of 16
136
If you actually make use of Spring Boot run configurations (currently only supported in the Ultimate Edition) it's easy to pre-configure the profiles in "Active Profiles" setting.

JetBrains
jetbrains.com › help › idea › spring-boot.html
Spring Boot | IntelliJ IDEA Documentation
It includes all available properties from various configuration sources, such as application properties and environment variables. In Spring Boot version higher than 3.0, values provided by Spring Environment are fully sanitized (replaced with ...
