第一个jetty程序
在运行jetty-maven-plugin时,出现错误

jetty-maven-plugin静态文件保存不了

妙音 posted @ 2014年12月31日 11:08 in java , 4934 阅读

起因

为maven项目配置jetty-maven-plugin插件,以jetty:run方式运行,会出现静态文件保存不了的问题。原因是jetty内存映射文件来缓存静态文件. 解决方法是将jetty内存映射参数取消掉.

解决

找webdefault.xml文件

在下面路径找到webdefault.xml文件
C:\Users\Administrator\.m2\repository\org\eclipse\jetty\jetty-webapp\9.2.6.v20141205
如果安装了jetty服务器,在它的etc目录下也可以取到webdefault.xml文件

useFileMappedBuffer参数值改为false

webdefault.xml配置
<init-param>
  <param-name>useFileMappedBuffer</param-name>
  <param-value>false</param-value>
</init-param>

新增defaultsDescriptor配置项

<plugin>  
    <groupId>org.eclipse.jetty</groupId>  
    <artifactId>jetty-maven-plugin</artifactId>  
    <version>9.2.6.v20141205</version>  
    <configuration>
        <scanIntervalSeconds>0</scanIntervalSeconds>
        <webAppSourceDirectory>${basedir}/WebRoot</webAppSourceDirectory>
        <webApp>  
            <contextPath>/</contextPath>
            <war>${project.build.directory}/${project.build.finalName}.war</war>
            <!-- jetty9.2.6的defaultsDescriptor在<webApp>里,早期版本在<configuration>或者<webAppConfig>里 -->
            <defaultsDescriptor>${basedir}/WebRoot/resources/webdefault.xml</defaultsDescriptor>
        </webApp> 
</configuration>
</plugin>

webdefault.xml加载是否成功

控制台输出如下,表示加载了webdefualt.xml
[INFO] Web defaults = .... /WebRoot/resources/webdefault.xml

感受

上面方法虽然可以解决问题,但是很不好用. 如果jetty-maven-plugin能设计个开发模式设置,在易用性上会有更大提升.

参考资料

jetty-maven-plugin配置文档
maven文档
 
 
Avatar_small
Buy Instagram Likes 说:
2019年3月14日 17:45

Thank You for posting to amazing blog for every Instagram user. you do great services for all of us on the web. Buy Instagram likes at affordable price for your every post

Avatar_small
huidbehandelingen ro 说:
2019年3月16日 17:18

This is very useful post for me. This will absolutely going to help me in my project.

Avatar_small
ogłoszenia erotyczne 说:
2019年3月25日 23:49

You're the best to share us about this redesign. Trust you won't get tired on making posts as enlightening as this.

Avatar_small
youtube promotion 说:
2019年4月03日 01:54

This is a decent post. This post gives really quality data. I'm unquestionably going to investigate it. Truly exceptionally valuable tips are given here. Much obliged to you to such an extent. Keep up the acts of kindness.

Avatar_small
Lahore escorts 说:
2019年4月07日 17:46

Excellent .. Amazing .. I’ll bookmark your blog and take the feeds also…I’m happy to find so many useful info here in the post, we need work out more techniques in this regard, thanks for sharing.

Avatar_small
Judi Online 说:
2019年4月12日 00:24

including reasonable comments here...

Avatar_small
assistir series hd 说:
2019年4月15日 11:05

Thank you for your post, I look for such article along time, today i find it finally. this post give me lots of advise it is very useful for me.

Avatar_small
ver filmes online 说:
2019年4月15日 11:06

I have read some just right stuff here. Certainly value bookmarking for revisiting. I surprise how much attempt you place to make this type of excellent informative website.

Avatar_small
prostytutki 说:
2019年5月22日 15:24

Escorts can be both male and female,but they are mostly smart,sexy,intelliegnt,good looking ,modern and well mannered.

Avatar_small
EPOXY LANTAI 说:
2019年5月23日 20:08

Thank you very much for keep this information.

Avatar_small
voyante telephone 说:
2019年5月31日 17:36

Excellent information on your blog, thank you for taking the time to share with us. Amazing insight you have on this, it's nice to find a website that details so much information about different artists.

Avatar_small
marketing1on1.com 说:
2019年6月08日 18:36

You must set clear goals to help you measure the success of your campaign.

Avatar_small
Judi Bola 说:
2019年6月10日 17:42

Your website is really cool and this is a great inspiring article.

Avatar_small
click to read more f 说:
2019年6月15日 18:25

Drop the mowers. This grass will not need mowing. Invest some time elsewhere than labor on trimming your lawn.


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter