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

查看:61
本文介绍了将用户定义的环境变量传递给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上:

设置APP_MASTER_PASSWORD = foo

在类似Unix的系统上:

On Unix like systems:

导出APP_MASTER_PASSWORD = foo

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

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