Jetty会使用内存映射文件来缓存静态文件,其中包括js、css文件。在Windows下面,使用内存映射文件会导致文件被锁定。解决方案是不使用内存映射文件来做缓存。步骤如下: 1)在所使用Jetty版本的jar中找到webdefault.xml, 把它拷贝到项目中,比如 src/main/resources/webdefault.xml。对jetty6 ,jar文件在$maven_repo$/org/mortbay/jetty/jetty/6.x/jetty-6.x.jar,webdefault.xml文件在包org\mortbay\jetty\webapp里;对jetty7 ,jar文件在$maven_repo$/org/eclipse/jetty/jetty-webapp/7.x/jetty-webapp-7.x.jar\,webdefault.xml文件在包org\eclipse\jetty\webapp里。 2)找到webdefault.xml文件里的 useFileMappedBuffer参数,把值设成false。 3)在pom.xml中,设置jetty使用更新过的webdefault.xml文件。 jetty6:<groupIdorg.mortbay.jetty</groupId <artifactIdmaven-jetty-plugin</artifactId <version6.x</version <configuration <webDefaultXml src/main/resources/webdefault.xml </webDefaultXml </configurationjetty7:<groupIdorg.mortbay.jetty</groupId <artifactIdjetty-maven-plugin</artifactId <version7.x</version <configuration <webAppConfig <defaultsDescriptor src/main/resources/webdefault.xml </defaultsDescriptor </webAppConfig </configuration 这样在运行时就可以修改js、css等文件了。 以上参照:http://zhidao.baidu.com/link?url=NaeTE0wBq84bR4VStb2COop3bO8PCLm8Dvy-o5CwG_2OkD_-GhrfZJ4Gvg8NzZSq6kt8LhsieoUjek6EO-J4aq 无法生效,后采用如下方式: 找到D:\maven\.m2\org\mortbay\jetty\jetty\6.1.25目录下jetty-6.1.25.jar,直接修改jar包中webDefaultXml 成功解决
maven+jetty运行时不锁定文件
最新推荐文章于 2017-07-19 15:17:42 发布