Jetty 9.0.6中无热部署
我已经通过context.xml为使用虚拟主机设置了Jetty上下文。因此,我的目录结构如下所示:Jetty 9.0.6中无热部署,jetty,Jetty,我已经通过context.xml为使用虚拟主机设置了Jetty上下文。因此,我的目录结构如下所示: webapps --mycontext.xml --mycontext.war 现在,当我上传一个新的war时,不再发生热部署。只有在修改mycontext.xml时才会发生这种情况。当我在没有mycontext.xml的情况下工作时,情况并非如此 下面是mycontext.xml的内容 <?xml version="1.0" encoding="ISO-8859-1"?> <
webapps
--mycontext.xml
--mycontext.war
现在,当我上传一个新的war时,不再发生热部署。只有在修改mycontext.xml时才会发生这种情况。当我在没有mycontext.xml的情况下工作时,情况并非如此
下面是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>
/
/mycontext.war
example.com
www.example.com
本地服务器
127.0.0.1
您知道如何通过更新war文件重新获得热部署吗?您需要将mycontext.xml放在服务器的contexts目录中。此外,您可能需要在etc/jetty-deploy.xml中为webapps目录中的war文件启用热部署,如前所述。如您所见,配置启用了热部署
......
<Set name="monitoredDirName"><Property name="jetty.home" default="." />/webapps</Set>
.....
。。。。。。
/网络应用
.....
以下是对我有效的配置
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>
/mycontext
/webapps/mycontext.war
example.com
www.example.com
本地服务器
127.0.0.1
请注意我是如何提供war文件名和位置的
<Set name="war"><SystemProperty name="jetty.home"/>/webapps/mycontext.war</Set>
/webapps/mycontext.war
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>
org.eclipse.jetty.server.webapp.ContainerIncludeJarPattern
.*/servlet api-[^/]*\.jar$
/网络应用
/etc/webdefault.xml
1.
符合事实的
有了这个配置,当我在webapps中添加一个修改后的mycontext.war时,jetty很高兴
重新部署战争。对我不起作用。就我所见,我的配置的唯一区别是您提供war路径的方式。我已经试过了,但是jetty.home/webapps和jetty.webapps应该是相等的。我的解决方法是在自动分发过程中接触mycontext.xml。现在已经足够了。这看起来像个bug。我在谢谢你的网站上为你提出了一个问题。我真的很感激你的工作。