如何让Jetty动态加载“静态”网页 [英] How to make Jetty dynamically load "static" pages

查看:100
本文介绍了如何让Jetty动态加载“静态”网页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建Java Web应用程序,我讨厌传统的代码编译 - 部署 - 测试循环。我想输入一个微小的变化,然后立即查看结果,而不必编译和部署。

I am building Java web applications, and I hate the traditional "code-compile-deploy-test" cycle. I want to type in one tiny change, then see the result INSTANTLY, without having to compile and deploy.

幸运的是, Jetty 非常棒。它是一个纯java的Web服务器。它附带了一个非常好的 maven插件,可让您直接启动Jetty阅读来自您的构建树 - 无需打包war文件或部署。它甚至还有一个scanInterval设置:将它设置为非零值,它将监视您的java文件和各种配置文件以进行更改,并在您进行更改后自动重新部署几秒钟。

Fortunately, Jetty is great for this. It is a pure-java web server. It comes with a really nice maven plugin which lets you launch Jetty reading directly from your build tree -- no need to package a war file or deploy. It even has a scanInterval setting: put this to a non-zero value and it will watch your java files and various config files for changes and automatically re-deploy a few seconds after you make a change.

只有一件事让我远离天堂。我的src / main / webapp目录中有javascript和css文件,这些文件只能由Jetty提供。我希望能够编辑这些,并在浏览器中刷新页面时显示更改。不幸的是,Jetty将这些文件保持打开状态,因此我不能(在Windows上)在运行时修改它们。

There's just one thing keeping me from nirvana. I have javascript and css files in my src/main/webapp directory which just get served up by Jetty. I would like to be able to edit these and have the changes show up when I refresh the page in the browser. Unfortunately, Jetty holds these files open so I can't (on Windows) modify them while it is running.

有没有人知道如何让Jetty放开这些文件所以我可以编辑它们,然后为后续请求提供编辑后的文件?

Does anyone know how to make Jetty let go of these files so I can edit them, then serve up the edited files for subsequent requests?

推荐答案

Jetty使用内存映射文件缓冲静态content,导致Windows中的文件锁定。尝试将DefaultServlet的useFileMappedBuffer设置为false。

Jetty uses memory-mapped files to buffer static content, which causes the file-locking in Windows. Try setting useFileMappedBuffer for DefaultServlet to false.

疑难解答Windows上的锁定文件(来自Jetty wiki)有说明。

这篇关于如何让Jetty动态加载“静态”网页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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