jetty插件禁止热部署_嵌入式Jetty 8热部署类(使用Maven)

I have a standard Maven webapp structure defined, and it uses Spring MVC.

I am using an embedded Jetty server (java class) for testing the application in development.

The code used to create the Jetty server is outlined below. If I make changes to any JSP files, the changes are immediately visible in the browser.

However if I change any class files, e.g Controllers, the changes are not hot deployed?

What do I have to do get this to work?

I have searched this and I think I need to use the class org.eclipse.jetty.util.Scanner and specifically the setScanInterval method, but not sure how to wire this up?

Here is the code to create the Server

String webAppDir = "src/main/webapp/";

Server server = new Server(8080);

WebAppContext webApp = new WebAppContext();

webApp.setContextPath("/");

webApp.setDescriptor(webAppDir + "/WEB-INF/web.xml");

webApp.setResourceBase(webAppDir);

webApp.setParentLoaderPriority(true);

HandlerCollection hc = new HandlerCollection();

ContextHandlerCollection contextHandlerCollection = new ContextHandlerCollection();

hc.setHandlers(new Handler[] { contextHandlerCollection });

hc.addHandler(webApp);

server.setHandler(hc);

return server;

Thanks in advance

解决方案

For hot deployment you need to use the WebAppProvider and the DeploymentManager. Those you can configure to manage the scanning for changes and the reloading of the webapp. So it is clear, the WebappContext is not what manages the deployment of a webapp, it is merely the container class that is gets deployed so there is another mechanism that works outside of that which can handle the concepts of deploy/redeploy.

You can take that chunk of xml there and convert into the java calls you need to do this embedded.

Or use something like the jrebel jvm plugin which provides for automatic class reloading.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值