IntelliJ:使用存储在单独文件中的环境变量执行程序 [英] IntelliJ : executing a program with environment variables stored in a separated file

查看:175
本文介绍了IntelliJ:使用存储在单独文件中的环境变量执行程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序需要自定义环境变量才能运行. 我已经在IntelliJ中创建了运行配置以启动应用程序.对于环境变量,我设置了VM选项.

My application needs custom environment variables to run. I have created a run configuration in IntelliJ in order to start the application. For environment variables, I have set VM options.

示例:

-DDATABASE_URL=jdbc:oracle:thin:@dbbdevdb0397.fr:1522:DBZD08

我担心的是自动在IntelliJ配置中添加所有环境变量. 这就是为什么我在单独的文件中设置这些环境变量

My concerns is to add all environment variables in my IntelliJ configuration automatically. That is why I have set these environment variables inside a separated file

示例:DEV.env

Example : DEV.env

DATABASE_URL=jdbc:oracle:thin:@dbbdevdb0397.fr:1522:DBZD08

是否可以像通过SH脚本那样在IntelliJ运行配置中加载此文件DEV.env:

Is it possible to load this file DEV.env in a IntelliJ run configuration as it could be done by SH script:

eval $(cat DEV.env | sed 's/^/export /');

推荐答案

截至2017年3月14日,似乎有人编写了允许该插件的插件.

As of March 14th 2017 it appears that someone has written a plugin which allows this.

打开设置,然后选择插件 在搜索框中搜索".env文件支持"并进行安装. 重新启动IntelliJ之后,您将在运行配置"屏幕中获得一个名为EnvFile的新选项卡. EnvFile选项卡将具有一个启用EnvFile支持的复选框,以及一个列表,您可以在其中指定要在启动该特定运行配置之前加载的env文件.您需要为每个运行配置设置env文件选项.

Open settings, then select plugins In the search box search for ".env files support" and install it. After restarting IntelliJ you will have a new tab in the Run Configurations screen called EnvFile. The EnvFile tab will have a checkbox for enabling EnvFile support and a list where you can specify the env files you want to load prior to launching that specific run configuration; you need to set the env file option up for each run configuration.

我有一个与您相似的用例,它适用于我指定与运行配置关联的env文件.

I have a similar use case to yours and it works for me in specifying env files associated with a run configuration.

有关插件的其他信息: https://plugins.jetbrains.com/plugin/7861-env-file

Additional Information on the plugin: https://plugins.jetbrains.com/plugin/7861-env-file

这篇关于IntelliJ:使用存储在单独文件中的环境变量执行程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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