maven jetty 热部署 Files are locked on Windows and can't be replaced
来源:互联网 发布:淘宝复制宝贝有影响吗 编辑:程序博客网 时间:2024/05/18 10:18
在windows操作系统用jetty maven plugin运行jetty:run命令,修改静态html等资源后不能保存,出现文件被锁问题。
原因:maven jetty plugin 的默认webdefault.xml中的default servlet的初始参数useFileMappedBuffer值为true。
Jetty buffers static content for webapps such as html files, css files, images etc and uses memory mapped files to do this if the NIO connectors are being used. The problem is that on Windows, memory mapping a file causes the file to be locked, so that the file cannot be updated or replaced. See Sun bug: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4715154. This means that effectively you have to stop Jetty in order to update a file.
<servlet> <servlet-name>default</servlet-name> <servlet-class>org.eclipse.jetty.servlet.DefaultServlet</servlet-class> <init-param> <param-name>aliases</param-name> <param-value>false</param-value> </init-param> <init-param> <param-name>acceptRanges</param-name> <param-value>true</param-value> </init-param> <init-param> <param-name>dirAllowed</param-name> <param-value>true</param-value> </init-param> <init-param> <param-name>welcomeServlets</param-name> <param-value>false</param-value> </init-param> <init-param> <param-name>redirectWelcome</param-name> <param-value>false</param-value> </init-param> <init-param> <param-name>maxCacheSize</param-name> <param-value>256000000</param-value> </init-param> <init-param> <param-name>maxCachedFileSize</param-name> <param-value>200000000</param-value> </init-param> <init-param> <param-name>maxCachedFiles</param-name> <param-value>2048</param-value> </init-param> <init-param> <param-name>gzip</param-name> <param-value>false</param-value> </init-param> <init-param> <param-name>etags</param-name> <param-value>false</param-value> </init-param> <init-param> <param-name>useFileMappedBuffer</param-name> <param-value>true</param-value> </init-param> <!-- <init-param> <param-name>resourceCache</param-name> <param-value>resourceCache</param-value> </init-param> --> <!-- <init-param> <param-name>cacheControl</param-name> <param-value>max-age=3600,public</param-value> </init-param> --> <load-on-startup>0</load-on-startup> </servlet>
<servlet-mapping> <servlet-name>default</servlet-name> <url-pattern>/</url-pattern> </servlet-mapping>
解决:
1.可以拷贝一份webdefault.xml到工程的resources目录修改参数useFileMappedBuffer为false。并在plugin的configuration配置如下参数
<plugin> ... <artifactId>jetty-maven-plugin</artifactId> <configuration> <webAppConfig> ... <defaultsDescriptor>/my/path/to/webdefault.xml</defaultsDescriptor> </webAppConfig> </configuration></plugin>
2.
在web.xml 添加如下参数
jetty plugin groupId为org.eclipse.jetty 添加
<context-param>
<param-name>org.eclipse.jetty.servlet.Default.useFileMappedBuffer</param-name>
<param-value>false</param-value>
</context-param>
====================================================================================
jetty plugin groupId为org.mortbay.jetty 添加
<context-param>
<param-name>org.mortbay.jetty.servlet.Default.useFileMappedBuffer</param-name>
<param-value>false</param-value>
</context-param>
参考:
http://www.eclipse.org/jetty/documentation/current/troubleshooting-locked-files-on-windows.html
http://docs.codehaus.org/display/JETTY/Files+locked+on+Windows
- maven jetty 热部署 Files are locked on Windows and can't be replaced
- Jetty( Files locked on Windows )转http://docs.codehaus.org/display/JETTY/Files+locked+on+Windows
- maven-jetty热部署
- eclipse maven jetty 热部署
- maven热部署插件-jetty
- This tag and its children can be replaced
- [Java] JRebel + Maven + Jetty 热部署
- eclipse + maven + jetty + jrebel 热部署搭建
- maven + jetty + eclipse热部署(hot code)
- jetty-maven-plugin实现热部署
- intellij +maven + jetty实现热部署
- idea maven jetty插件热部署
- Program Files\android-sdk-windows\platform-tools\adb.exe' and can be executed.
- This tag and its children can be replaced by one <TextView/> and a compound drawable
- This tag and its children can be replaced by one <TextView/> and a compound drawable
- This tag and its children can be replaced by one <TextView/> and a compound drawable
- This tag and its children can be replaced by one <TextView/> and a compound drawable
- This tag and its children can be replaced by one <TextView/> and a compound drawable
- 基于jrtplib的rtp数据发送
- curl使用
- 3G模块拨号上网设置APN,拨号号码,帐号和密码
- 【CSDN常见问题解答】JSON和XML格式互相转换
- POJ 3693 Maximum repetition substring
- maven jetty 热部署 Files are locked on Windows and can't be replaced
- 用于showdialog的js源码
- VirtualBox 修改UUID实现虚拟硬盘复制
- PowerDesigner显示注释问题
- 单链表的就地逆转
- PHP根据中国天气获取本地程式天气
- Oracle学习随笔
- ContentProvider(1):杂言
- 如何从本机直接复制粘贴文件到服务器