在 Tomcat/Catalina Context docBase 配置中使用环境变量

发布于 2025-01-02 16:47:19 字数 316 浏览 5 评论 0原文

我不是tomcat的大用户,但我们的项目目前正在使用它。我们已经提交了一个 .xml 配置文件,该文件放置在 CATALINA_HOME\localhost 中,但更新得相当频繁。我更愿意将此文件从我们的工作目录符号链接到 CATALINA_HOME\localhost 目录中。不幸的是,每个开发人员都必须修改 docBase 路径。

有没有办法在 docBase 路径中使用环境变量,以便开发人员可以将他们的项目保留在他们喜欢的位置,并且我们的启动脚本可以符号链接 catalina xml 配置?

我想要这样的东西:

....

I'm not a big tomcat user, but our project is using it currently. We've committed a .xml configuration file that is placed in CATALINA_HOME\localhost, but get's updated rather often. I would much prefer to symlink this file into that CATALINA_HOME\localhost directory from our working directory. Unfortunately, the docBase path has to be modified per developer.

Is there a way to use environment variables in the docBase path so that developers can keep their projects where they please and our startup scripts can symlink the catalina xml configuration?

I would like something like this:

....

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

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

发布评论

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

评论(1

屋顶上的小猫咪 2025-01-09 16:47:19

这是我在 Tomcat7 中所做的(我认为在 Tomcat 的其他版本中执行此操作不会有任何问题):

在 setenv.bat 中,我添加了以下行:

set JAVA_OPTS=%JAVA_OPTS% -DAPP_PATH="c:\path\to\app"

在我的 webapp.xml 中(位于 C:\path-to-apache 中) -tomcat\conf\Catalina\localhost)

我做了以下操作:

<Context docBase="${APP_PATH}\src\main\webapp">

希望这有帮助!

Here's what I did in Tomcat7 (I think you'll have no problem doing it in other versions of Tomcat):

in setenv.bat I added the following line:

set JAVA_OPTS=%JAVA_OPTS% -DAPP_PATH="c:\path\to\app"

in my webapp.xml (located in C:\path-to-apache-tomcat\conf\Catalina\localhost)

I did the following:

<Context docBase="${APP_PATH}\src\main\webapp">

Hope this helps!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文