在 Tomcat 6 中添加 java_opts 参数

发布于 2024-12-19 21:33:56 字数 83 浏览 5 评论 0原文

我需要在 Tomcat 中添加 -DAPP_ENCRYPTION_PASSWORD 来启动应用程序。 任何人都可以准确指出在哪里添加此参数吗?又如何呢?

I have a requirement to add -DAPP_ENCRYPTION_PASSWORD in Tomcat to start an application.
Can any one point exactly where to add this parameter? And how?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

电影里的梦 2024-12-26 21:33:56

为 Tomcat 设置环境变量的简单且首选的方法是通过 bin/setenv.sh 脚本。请参阅:如何不使用配置程序来调整 Tomcat 5.5 JVM 内存设置

或者这样:https://stackoverflow.com/search?q=setenv.sh

The simple and preferred way to set environment variables for Tomcat is via the bin/setenv.sh script. See this: How to tune Tomcat 5.5 JVM Memory settings without using the configuration program

Or this: https://stackoverflow.com/search?q=setenv.sh

并安 2024-12-26 21:33:56

这完全取决于您计划如何启动 Tomcat。 Tomcat 本身希望运行一个 shell 脚本,该脚本通常位于 $TOMCAT_HOME/bin/catalina.sh(Windows 上有一个等效的 .bat 文件)。该文件内部描述了 tomcat 对环境的期望。如果您想将 -DAPP_ENCRYPTION_PASSWORD 系统属性添加到 Tomcat 的启动中,我想您只需弄清楚如何将其在环境中设置为 JAVA_OPTS 即可。

如果你绝望并且想避免设置环境,我想你可以直接编辑catalina.sh。

环境变量序列看起来像...

  1. 从命令 shell 更改到 tomcat 所在的目录
    从命令 shell部署
  2. ,从命令 shell 切换到 tomcat 下的“bin”目录
  3. ,从命令 shell 设置 JAVA_OPTS 环境变量,如“JAVA_OPTS=-DAPP_ENCRYPTION_PASSWORD”
  4. ,启动 tomcat,如“./startup.sh

”会看起来像...

bobk-mbp:~ bobk$ cd work/apache-tomcat-6.0.35/
bobk-mbp:apache-tomcat-6.0.35 bobk$ cd bin
bobk-mbp:bin bobk$ JAVA_OPTS=-DAPP_ENCRYPTION_PASSWORD
bobk-mbp:bin bobk$ ./startup.sh 
Using CATALINA_BASE:   /Users/bobk/work/apache-tomcat-6.0.35
Using CATALINA_HOME:   /Users/bobk/work/apache-tomcat-6.0.35
Using CATALINA_TMPDIR: /Users/bobk/work/apache-tomcat-6.0.35/temp
Using JRE_HOME:        /Library/Java/Home
Using CLASSPATH:       /Users/bobk/work/apache-tomcat-6.0.35/bin/bootstrap.jar

It all depends on how you plan to start Tomcat. Tomcat itself wants to be run a shell script that's typically located at $TOMCAT_HOME/bin/catalina.sh (there's an equivalent .bat file for windows). Inside of that file it describes what tomcat expects for an environment. If you want to get your -DAPP_ENCRYPTION_PASSWORD system property into the startup of Tomcat, I think you just figure out how to get it set up in the environment as JAVA_OPTS and you are on your way.

If you are desperate and want to avoid setting up the environment, I suppose that you could edit catalina.sh directly.

The environment variable sequence looks like...

  1. from a command shell, change to the directory where tomcat
    is deployed
  2. from a command shell, change to the "bin" directory under tomcat
  3. from a command shell, set the JAVA_OPTS evironment variable like "JAVA_OPTS=-DAPP_ENCRYPTION_PASSWORD"
  4. from a command shell, start tomcat like "./startup.sh"

The output will look like...

bobk-mbp:~ bobk$ cd work/apache-tomcat-6.0.35/
bobk-mbp:apache-tomcat-6.0.35 bobk$ cd bin
bobk-mbp:bin bobk$ JAVA_OPTS=-DAPP_ENCRYPTION_PASSWORD
bobk-mbp:bin bobk$ ./startup.sh 
Using CATALINA_BASE:   /Users/bobk/work/apache-tomcat-6.0.35
Using CATALINA_HOME:   /Users/bobk/work/apache-tomcat-6.0.35
Using CATALINA_TMPDIR: /Users/bobk/work/apache-tomcat-6.0.35/temp
Using JRE_HOME:        /Library/Java/Home
Using CLASSPATH:       /Users/bobk/work/apache-tomcat-6.0.35/bin/bootstrap.jar
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文