Jetty 9.0.6中没有热部署 [英] No hot deployment in Jetty 9.0.6

查看:99
本文介绍了Jetty 9.0.6中没有热部署的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经通过context.xml设置了一个Jetty上下文来使用虚拟主机.所以我的目录结构如下:

I have set up a Jetty context by a context.xml for using virtual hosts. So my directory structure looks like this:

webapps
--mycontext.xml
--mycontext.war

现在,当我上传新的战争时,不再发生热部署.仅当我修改mycontext.xml时才会发生.当我没有mycontext.xml时,情况并非如此.

Now when i upload a new war, no hot deployment occurs any more. It only happens when i modify mycontext.xml. That was not the case when i worked without a mycontext.xml.

这是mycontext.xml的内容

Here is the content of mycontext.xml

<?xml version="1.0"  encoding="ISO-8859-1"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_0.dtd">

<Configure class="org.eclipse.jetty.webapp.WebAppContext">

 <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
 <!-- Required minimal context configuration :                        -->
 <!--  + contextPath                                                  -->
 <!--  + war OR resourceBase                                          -->
 <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
 <Set name="contextPath">/</Set>
 <Set name="war"><Property name="jetty.webapps" default="."/>/mycontext.war</Set>

 <Set name="virtualHosts">
   <Array type="String">
     <Item>example.com</Item>
      <Item>www.example.com</Item>
      <Item>localhost</Item>
     <Item>127.0.0.1</Item>
   </Array>
 </Set>
</Configure>

有什么想法可以通过更新war文件来重新获得热部署?

Any ideas how i regain hot deployment by updating the war file?

推荐答案

您需要将mycontext.xml放在服务器的contexts目录中.您还可能需要在etc/jetty-deploy.xml中为webapps目录中的war文件启用热部署,如

You need to put your mycontext.xml in the contexts directory of your server. Also you probably need to enable hot deployment in etc/jetty-deploy.xml for the war files in webapps directory as mentioned here. As you can see the configuration enables the hot deployment

......
 <Set name="monitoredDirName"><Property name="jetty.home" default="." />/webapps</Set>
.....

以下是对我有用的配置

jetty.home/contextx/mycontext.xml

jetty.home/contextx/mycontext.xml

<?xml version="1.0"  encoding="ISO-8859-1"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_0.dtd">

<Configure class="org.eclipse.jetty.webapp.WebAppContext">

 <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
 <!-- Required minimal context configuration :                        -->
 <!--  + contextPath                                                  -->
 <!--  + war OR resourceBase                                          -->
 <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
 <Set name="contextPath">/mycontext</Set>
 <Set name="war"><SystemProperty name="jetty.home"/>/webapps/mycontext.war</Set>

 <Set name="virtualHosts">
   <Array type="String">
     <Item>example.com</Item>
      <Item>www.example.com</Item>
      <Item>localhost</Item>
     <Item>127.0.0.1</Item>
   </Array>
 </Set>
</Configure>

请注意我如何提供战争文件的名称和位置

Please note how I have supplied the war file name and location

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

jetty.home/etc/jetty-deploy.xml

jetty.home/etc/jetty-deploy.xml

<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure.dtd">

<!-- =============================================================== -->
<!-- Create the deployment manager                                   -->
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
<!-- The deplyment manager handles the lifecycle of deploying web    -->
<!-- applications. Apps are provided by instances of the             -->
<!-- AppProvider interface.  Typically these are provided by         -->
<!-- one or more of:                                                 -->
<!--   jetty-webapps.xml       - monitors webapps for wars and dirs  -->
<!--   jetty-contexts.xml      - monitors contexts for context xml   -->
<!--   jetty-templates.xml     - monitors contexts and templates     -->
<!-- =============================================================== -->
<Configure id="Server" class="org.eclipse.jetty.server.Server">

    <Call name="addBean">
      <Arg>
        <New id="DeploymentManager" class="org.eclipse.jetty.deploy.DeploymentManager">
          <Set name="contexts">
            <Ref id="Contexts" />
          </Set>
          <Call name="setContextAttribute">
            <Arg>org.eclipse.jetty.server.webapp.ContainerIncludeJarPattern</Arg>
            <Arg>.*/servlet-api-[^/]*\.jar$</Arg>
          </Call>


          <Call id="webappprovider" name="addAppProvider">
          <Arg>
            <New class="org.eclipse.jetty.deploy.providers.WebAppProvider">
              <Set name="monitoredDirName"><Property name="jetty.home" default="." />/webapps</Set>
              <Set name="defaultsDescriptor"><Property name="jetty.home" default="." />/etc/webdefault.xml</Set>
              <Set name="scanInterval">1</Set>
              <Set name="extractWars">true</Set>
            </New>
          </Arg>
        </Call>

        </New>
      </Arg>
    </Call>
</Configure>

使用此配置,当我将修改后的mycontext.war放到webapps中时,很高兴地跳船 重新部署战争.

With this configuration, when I put a modified mycontext.war in webapps, jetty happily redeploys the war.

这篇关于Jetty 9.0.6中没有热部署的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆