将用户定义的环境变量传递给 tomcat [英] Pass user defined environment variable to tomcat

查看:22
本文介绍了将用户定义的环境变量传递给 tomcat的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Eclipse 进行 Web 应用程序编码.在此我传递了环境变量,如:

I am using the eclipse for web application coding. Within this I passed environment variable like :

  1. 项目-->运行方式 -->运行配置.并选择环境标签.
  2. 添加名为 APP_MASTER_PASSWORD 的新环境变量及其值.
  1. Project--> Run as --> Run Configuration. And selected Environment tab.
  2. Add new environment variable with name APP_MASTER_PASSWORD and its value.

我可以在 java 代码中以 System.getenv("APP_MASTER_PASSWORD") 的形式访问这个值.

I can access this value in java code as System.getenv("APP_MASTER_PASSWORD").

但现在我想将此环境变量传递给 tomcat 并在应用程序中访问它,而不是通过 eclipse.

But now I want to pass this environment variable to tomcat and access it in application instead of passing thru eclipse.

那么如何将这样的变量传递给 tomcat?

So how can I pass such variable to tomcat?

我用谷歌搜索了一下.但我没有得到任何解决方案.

I googled about it. But I didn't get any solution.

推荐答案

您可以使用 setenv.bat 或 .sh 将环境变量传递给 Tomcat.

You can use setenv.bat or .sh to pass the environment variables to the Tomcat.

创建CATALINA_BASE/bin/setenv.bat 或.sh 文件并在其中添加以下行,然后启动Tomcat.

Create CATALINA_BASE/bin/setenv.bat or .sh file and put the following line in it, and then start the Tomcat.

在 Windows 上:

On Windows:

设置APP_MASTER_PASSWORD=foo

在类 Unix 系统上:

On Unix like systems:

导出APP_MASTER_PASSWORD=foo

这篇关于将用户定义的环境变量传递给 tomcat的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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