在码头热部署简单的应用程序

Cas*_*sey 1 java jetty java-ee

我目前正在使用jetty hightide vesion 7作为独立服务器.我有一个简单的Web项目,其中包含一些jsp和支持类,我目前正在未爆炸的战争中部署到JETTY_HOME/webapps目录.

目前,jetty可以轻松获取任何静态jsp/html更改.如果我理解正确,我可以配置我的应用程序,以便jetty将在不重新启动服务器的情况下获取任何类更改?我目前在我的jetty-web.xml中:

<?xml version="1.0"  encoding="ISO-8859-1"?>
<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN" "http://www.eclipse.org/jetty/configure.dtd">

<!--
    This is the jetty specific web application configuration file. When
    starting a Web Application, the WEB-INF/web-jetty.xml file is looked
    for and if found, treated as a
    org.eclipse.jetty.server.server.xml.XmlConfiguration file and is
    applied to the org.eclipse.jetty.servlet.WebApplicationContext objet
-->

<Configure class="org.eclipse.jetty.webapp.WebAppContext">
<Call class="org.eclipse.jetty.util.log.Log" name="debug">
    <Arg>executing jetty-web.xml</Arg>
</Call>
<Set name="contextPath">/SimpleDynamicProject</Set>

</Configure>
Run Code Online (Sandbox Code Playgroud)

我还创建了一个SimpleDynamicProject.xml并将其放在JETTY_HOME/contexts中.该文件包含:

<?xml version="1.0"  encoding="ISO-8859-1"?>
<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN" "http://www.eclipse.org/jetty/configure.dtd">

<!--
    This is the jetty specific web application configuration file. When
    starting a Web Application, the WEB-INF/web-jetty.xml file is looked
    for and if found, treated as a
    org.eclipse.jetty.server.server.xml.XmlConfiguration file and is
    applied to the org.eclipse.jetty.servlet.WebApplicationContext objet
-->

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

<Set name="contextPath">/SimpleDynamicProject</Set>
<Set name="resourceBase"><SystemProperty name="jetty.home" default="."/>/webapps/SimpleDynamicProject</Set>
</Configure>
Run Code Online (Sandbox Code Playgroud)

我也不确定如何在调试模式下正确启动Jetty,我也需要它.我尝试使用以下命令启动服务器:

java -Xdebug -jar start.jar OPTIONS=Server,jsp
Run Code Online (Sandbox Code Playgroud)

java -Ddebug -jar start.jar OPTIONS=Server,jsp
Run Code Online (Sandbox Code Playgroud)

这是我第一次使用码头,但到目前为止我真的很喜欢它.

谢谢您的帮助.

Pas*_*ent 5

您需要定义一个非零扫描间隔的ContextDeployer:

<Call name="addLifeCycle">
  <Arg>
    <New class="org.mortbay.jetty.deployer.ContextDeployer">
      <Set name="contexts"><Ref id="Contexts"/></Set>
      <Set name="configurationDir"><SystemProperty name="jetty.home" default="."/>/contexts</Set>
      <Set name="scanInterval">1</Set>
    </New>
  </Arg>
</Call>
Run Code Online (Sandbox Code Playgroud)

关于调试,我想您的想法是使用JPDA连接远程调试器.为此,您需要设置-agentlib:jdwp选项1:

-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005
Run Code Online (Sandbox Code Playgroud)

配置IDE调试器以在指定端口上进行连接.

1如果目标VM是5.0或更新的,-agentlib:jdwp是在优选的-Xdebug-Xrunjdwp选项目前仍在虽然支持.