IntelliJ Tomcat运行配置未设置环境变量 [英] IntelliJ Tomcat Run Configuration Does Not Set Environment Variables

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

问题描述

我正在使用IntelliJ Ultimate 2016.1.2在OS X上运行Tomcat 8.0.35。我想在调试器下本地运行Tomcat并将其Web应用程序部署到它。我创建了本地Tomcat Server运行配置。在部署选项卡中,我指定了要部署的WAR文件。

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.

我的Web应用程序需要 REDIS_HOST_MM REDIS_PORT_MM 环境变量。我在运行配置的启动/连接选项卡中进行设置。

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启动并部署了我的Web应用程序,但是未设置环境变量。我可以在Web应用程序的代码中的下一行上放置一个断点

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

并看到当 value 等于 REDIS_HOST_MM ,该调用将返回 null

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

如果我在服务器选项卡中设置了虚拟机选项,则会遇到相同的问题到 -DREDIS_HOST_MM = 127.0.0.1 -DREDIS_PORT_MM = 6379 。另外,如果我将启动脚本更改为指向以下shell脚本

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

如果我从IntelliJ命令行启动Tomcat,则环境变量设置正确。

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

这是一个错误吗?在IntelliJ中,还是应该以其他方式设置环境变量?

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

这是JetBrains支持问题 699091

推荐答案

没关系。用户错误。我没有意识到您必须为运行和调试配置分别设置环境变量。我已经将它们设置为运行,但是我正在运行Debug。

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.

一旦我也为Debug配置设置了环境变量,一切正常。

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

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

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