IntelliJ IDEA全局环境变量配置 [英] IntelliJ IDEA global environment variable configuration

查看:7644
本文介绍了IntelliJ IDEA全局环境变量配置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在所有想法运行配置中使用envirnoment变量。我目前使用运行 - > 编辑配置 - > ,然后在所选配置中输入env变量。然而,当我需要运行隔离的测试场景时,这非常繁琐,因为每个都创建了一个新的运行配置,我需要重新输入变量。

I need to use an envirnoment variable in all of my idea run configurations. I currently use run->edit configurations->and then enter the env variables in selected configuration. However that's very tedious when I need to run isolated test scenarios because each one creates a new run configuration and I need to enter the variables all over again.

我尝试在各个会话中使用 export SOME_VAR =some value在我的linux系统中设置env变量配置文件: / etc / profile /etc/bash.bashrc 〜/。 bashrc 〜/ .profile 但是intellij似乎在运行期间忽略了这些变量,即使我启动 echo $ {来自intellij内置终端的SOME_VAR} 显示正确的输出。

I tried to set the env variables in my linux system using export SOME_VAR="some value" in various session profile files: /etc/profile,/etc/bash.bashrc,~/.bashrc,~/.profile but intellij seems to ignore those vars during run, even though when I launch echo ${SOME_VAR} from intellij built-in terminal it displays the correct output.

我也尝试使用 intellij .env文件插件然后设置 SOME_VAR =某个值 in项目根目录中的 .env 文件。也没用。

I also tried using intellij .env file plugin and then set SOME_VAR=some value in .env file in project root. Didn't work either.

推荐答案

如果使用Maven,可以在 文件 - >设置 - >构建下配置项目特定的环境变量,执行,部署 - >构建工具 - > Maven-> Runner
这些在任何Maven配置中都可以重复使用。

If Maven is used project specific environment variables can be configured under File->Settings->Build, Execution, Deployment->Build Tools->Maven->Runner These are reused then in any Maven configuration.

这篇关于IntelliJ IDEA全局环境变量配置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆