IntelliJ Tomcat Run Configuration Does Not Set Environment Variables

会有一股神秘感。 提交于 2020-01-24 20:28:45

问题


I am running Tomcat 8.0.35 on OS X with IntelliJ Ultimate 2016.1.2. I want to run Tomcat locally under the debugger and deploy my web application to it. I created a local Tomcat Server run configuration. In the Deployment tab I specified the WAR file to deploy.

My web application requires REDIS_HOST_MM and REDIS_PORT_MM environment variables to be set. I set these in the Startup/Connection tab of the run configuration.

Tomcat starts and my web application deploys, however, the environment variables are not set. I can put a breakpoint on the following line in my web application's code

String _value = System.getenv(value);

and see that when value equals "REDIS_HOST_MM", the call returns null.

I have the same problem if I set the VM Options in my Server tab to -DREDIS_HOST_MM=127.0.0.1 -DREDIS_PORT_MM=6379. Also if I change the Startup Script to point to the following shell script

export REDIS_HOST_MM=127.0.0.1
export REDIS_PORT_MM=6379
/usr/local/Cellar/tomcat/8.0.35/libexec/bin/catalina.sh run

If I start Tomcat outside IntelliJ from the command line, the environment variables are set correctly.

Is this a bug in IntelliJ, or am I supposed to set the environment variable in some other way?

(This is JetBrains support issue 699091.)


回答1:


Never mind. User error. I didn't realize you had to set environment variables separately for the Run and Debug configurations. I had them set for Run, but I was running Debug.

Once I set the environment variables for the Debug configuration too, everything worked.



来源:https://stackoverflow.com/questions/37603835/intellij-tomcat-run-configuration-does-not-set-environment-variables

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