将用户定义的环境变量传递给tomcat [英] Pass user defined environment variable to tomcat
问题描述
我正在使用Eclipse进行Web应用程序编码.我在其中传递了环境变量,如:
I am using the eclipse for web application coding. Within this I passed environment variable like :
- 项目->运行方式->运行配置.并选择环境"选项卡.
- 添加名称为
APP_MASTER_PASSWORD
及其值的新环境变量.
- Project--> Run as --> Run Configuration. And selected Environment tab.
- 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屋!