我的应用程序使用了Struts2 MVC、Spring模板以及Eclipse和Tomcat。每当我更改类代码时,我都必须重新启动Tomcat,这每次都会浪费15-20秒。
我已经配置了热部署,即java类更改,自动重新加载上下文,但是它经常失败,我必须重新启动Tomcat。
我想要的是:
如果有人使用过Jetty,请分享- Jetty是否为这些问题提供了更好的解决方案。
在PHP中,您可以修改脚本,并访问该页面。我只是希望它在Java。
发布于 2011-01-14 08:06:43
我们正在使用嵌入式Jetty在工作,这是一个爆炸。有关嵌入Jetty的指南,请参阅防波堤。
Jetty端的启动时间非常快(1-2秒)。但是,在我们的例子中,spring仍然需要大量的时间来初始化。
很容易配置Jetty来自动重新加载jsps,只需将它指向一个目录而不是war文件,jsp就会自动重新加载,如下所示:
public class OneWebAppUnassembled
{
public static void main(String[] args) throws Exception
{
Server server = new Server(8080);
WebAppContext context = new WebAppContext();
context.setDescriptor(webapp+"/WEB-INF/web.xml");
context.setResourceBase("../test-jetty-webapp/src/main/webapp");
context.setContextPath("/");
context.setParentLoaderPriority(true);
server.setHandler(context);
server.start();
server.join();
}
}类重新加载是可能的,使用热交换,我不知道是否有现成的解决方案,当热交换不工作。
发布于 2011-01-14 03:23:32
看看JRebel。你必须为此付出代价,但从长远来看,这可能是值得的,因为它节省了时间!)
发布于 2011-01-14 11:37:24
Tapestry5有活动类和模板重新加载,在Tomcat和Jetty工作。这使得发展速度快得多。
至于Tomcat之上的Jetty,我现在通常使用Jetty进行开发。它的启动速度非常快,而且非常可配置。您可以编写自己的简单服务器,并在eclipse中运行它,如下所示:
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.webapp.WebAppContext;
public class JettyServer {
public static void main(String[] args) throws Exception {
run(8080, "/path/to/eclipse/project/WebContent", "/WEB-INF/web.xml");
}
private static void run(int port, String resourceBase, String descriptor) throws Exception {
Server server = new Server(port);
WebAppContext context = new WebAppContext();
context.setResourceBase(resourceBase);
context.setDescriptor(resourceBase+descriptor);
context.setContextPath("/");
context.setParentLoaderPriority(true);
server.setHandler(context);
server.start();
server.join();
}
}https://stackoverflow.com/questions/4687677
复制相似问题