Setting up and using environment variables in IntelliJ Idea

我只是一个虾纸丫 提交于 2019-12-17 07:19:52

问题


I set up an environment variable (Under IDE Settings -> Path Variables)

 APP_HOME = /path/to/app_home  

One of my tests is failing however with

 System.out.println("APP HOME: " + APP_HOME); 

With

 APP HOME: null/ 

It does not look like that env variable is being read. What am i missing?


回答1:


Path Variables dialog has nothing to do with the environment variables.

Environment variables can be specified in your OS or customized in the Run configuration:




回答2:


In addition to the above answer and restarting the IDE didn't do, try restarting "Jetbrains Toolbox" if you use it, this did it for me




回答3:


It is possible to reference an intellij 'Path Variable' in an intellij 'Run Configuration'.

In 'Path Variables' create a variable for example ANALYTICS_VERSION.

In a 'Run Configuration' under 'Environment Variables' add for example the following:

ANALYTICS_LOAD_LOCATION=$MAVEN_REPOSITORY$\com\my\company\analytics\$ANALYTICS_VERSION$\bin

To answer the original question you would need to add an APP_HOME environment variable to your run configuration which references the path variable:

APP_HOME=$APP_HOME$


来源:https://stackoverflow.com/questions/13748784/setting-up-and-using-environment-variables-in-intellij-idea

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