IntelliJ : executing a program with environment variables stored in a separated file

风格不统一 提交于 2019-12-22 09:47:50

问题


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.

Example :

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

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

Example : DEV.env

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

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 /');

回答1:


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

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.

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

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



来源:https://stackoverflow.com/questions/45056727/intellij-executing-a-program-with-environment-variables-stored-in-a-separated

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!