【问题标题】:where can I find application specific context.xml file?在哪里可以找到特定于应用程序的 context.xml 文件?
【发布时间】:2023-04-02 16:35:01
【问题描述】:

我读到context.xml 文件(在 Tomcat 中) 是特定于应用程序的。我已经从我的 netbeans IDE 创建了两个 Web 项目,使用 Tomcat 作为服务器。但我找不到应用程序特定的 context.xml 文件。我只在Tomcat的conf目录中找到了context.xml

在哪里可以找到特定于应用程序的context.xml 文件?

【问题讨论】:

  • 应用程序特定的context.xml 不在项目/war 文件的META-INF/context.xml 中?

标签: java jakarta-ee tomcat context.xml


【解决方案1】:

根据我的经验和我从文档中看到的:

Context elements may be explicitly defined:
  • 在 $CATALINA_BASE/conf/context.xml 文件中:上下文元素 信息将由所有 webapps 加载。
  • 在 $CATALINA_BASE/conf/[enginename]/[hostname]/context.xml.default 文件: 上下文元素信息将由该的所有 webapps 加载 主持人。

取自here

【讨论】:

  • 正如你在上面粘贴的图片中看到的那样,我没有 catalina 目录。在这种情况下我该怎么办?
  • 特定于应用程序的context.xml 不在META-INF/context.xml 内?
  • 上面的第一个选项不是特定于应用程序的。例如,第二个是 conf/Catalina/localhost/yourappname.xml。该文件及其父目录(如果尚不存在)会在您部署战争时创建。这种方法允许您以不同的方式配置同一战争的两个实例。第三种选择是在战争本身中使用 context.xml。
【解决方案2】:

我注意到另一个答案中的链接是针对错误版本的 Tomcat。这是正确的文档:

http://tomcat.apache.org/tomcat-7.0-doc/config/context.html#Defining_a_context

正如您所见,现在的选项与以前的版本不同。根据我的经验,最常见的是选项 1:

In an individual file at /META-INF/context.xml inside the application files.

【讨论】:

  • 我没有看到任何名为应用程序文件的目录
  • 特定于应用程序的context.xml 不在META-INF/context.xml 内?
  • 我是说应用程序特定context.xml的最常见位置。
猜你喜欢
  • 2012-07-19
  • 2013-02-04
  • 2017-02-14
  • 1970-01-01
  • 2013-09-22
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多