【问题标题】:Context pointing to external directory in Jetty 9指向Jetty 9中外部目录的上下文
【发布时间】:2025-11-23 14:45:02
【问题描述】:

我想通过设置指向我的外部 .war(webapps 文件夹外部)的上下文来将 .war 文件部署到 Jetty。我知道如何在 Tomcat 中执行此操作,但我不知道如何为 Jetty 9 执行此操作。

在 Tomcat 中,我放置了一个 .xml 文件以在 $CATALINA_HOME/conf/Catalina/localhost 中配置我的上下文:

  <?xml version='1.0' encoding='utf-8'?>
  <!--  Context fragment for deploying ServletExample.war  -->
  <Context path="/CurrencyServlet" docBase="/Users/macbook/Desktop/School/Java/Temp/CurrencyServlet.war" debug="0" privileged="true"/>

谁能提供一个简单的 Jetty 9 示例?

【问题讨论】:

    标签: deployment jetty


    【解决方案1】:

    查看提供的 $jetty_home/webapps/test.xml 文件。在 jetty9 中,您可以通过在 $jetty_home/webapps 中放置一个 ContextProvider 配置文件来配置您的 webapps 等。

    查看文档:http://www.eclipse.org/jetty/documentation/current/configuring-contexts.html

    这是您配置 Web 应用路径的方式:

    <Set name="war"><SystemProperty name="jetty.home" default="."/>/webapps/test</Set>
    

    【讨论】: