windows Jetty Maven 插件忽略自定义 webdefault.xml

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4988019/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 16:10:25  来源:igfitidea点击:

Jetty Maven Plugin is ignoring custom webdefault.xml

windowsjettymaven-pluginmaven-3maven-jetty-plugin

提问by mckamey

I'm trying to get around the common issue of Jetty locking static files on Windowswith the technique of setting useFileMappedBufferto false in webdefault.xml. Unfortunately, every time Jetty is not picking up my customized webdefault.xml.

我试图通过在 webdefault.xml中设置为 false的技术来解决 Windows 上 Jetty 锁定静态文件常见问题useFileMappedBuffer。不幸的是,每次 Jetty 都没有选择我自定义的 webdefault.xml。

I'm using Apache Maven 3.0.2. I've tried using the maven-jetty-plugin (v6.1.26)and jetty-maven-plugin (v8.0.0.M2)but with no difference. I've tried running clean and rebuilding as well before running Jetty.

我正在使用 Apache Maven 3.0.2。我试过使用maven-jetty-plugin (v6.1.26)jetty-maven-plugin (v8.0.0.M2)但没有区别。在运行 Jetty 之前,我也尝试过运行清理和重建。

I've verified each time that my webdefault.xml was taken from the same version as the plugin and has the correct settings, namely, only changing this setting from true to false:

每次我都验证了我的 webdefault.xml 取自与插件相同的版本并且具有正确的设置,即,仅将此设置从 true 更改为 false:

...
<init-param>
  <param-name>useFileMappedBuffer</param-name>
  <param-value>false</param-value>
</init-param>
...

And here's what my pom.xml Jetty plugin section looks like:

这是我的 pom.xml Jetty 插件部分的样子:

<plugin>
    <groupId>org.mortbay.jetty</groupId>
    <artifactId>maven-jetty-plugin</artifactId>
    <configuration>
        <contextPath>/</contextPath>
        <webDefaultXml>src/main/resources/webdefault.xml</webDefaultXml>
    </configuration>
</plugin>

I've also tried altering the path to my file:

我也试过改变我的文件的路径:

<webDefaultXml>${basedir}/src/main/resources/webdefault.xml</webDefaultXml>

Everywhere I've seen this exact solutionand it sounds like it is working for others (although I found one instance where someone had my issue). The startup for jetty has this in the output:

我到处都看到了这个确切的解决方案,听起来它对其他人有用(尽管我发现有人遇到了我的问题)。码头的启动在输出中有这个:

> mvn jetty:run
...
[INFO] Web defaults = org/eclipse/jetty/webapp/webdefault.xml
[INFO] Web overrides = none
...

This further makes me think it isn't being applied. All the other paths are correct in the output.

这进一步让我认为它没有被应用。输出中的所有其他路径都是正确的。

My most direct issue that I'm seeing while Jetty is running is that whenever I edit a static file (JavaScript, CSS, etc.) with IntelliJ IDEA 10, I get this error message:

我在 Jetty 运行时看到的最直接的问题是,每当我使用 IntelliJ IDEA 10 编辑静态文件(JavaScript、CSS 等)时,我都会收到以下错误消息:

Cannot save file:
D:\...\... (The requested operation cannot be performed on a file with a user-mapped section open)

After I stop Jetty then it saves just fine. This happens every time.

在我停止 Jetty 之后,它保存得很好。每次都会发生这种情况。

Any ideas what I could be doing wrong?Thanks in advance.

任何想法我可能做错了什么?提前致谢。

回答by mckamey

I found an entirely different doc for the newer Jetty plugin jetty-maven-plugin (v8.0.0.M2) and it looks like the configuration name has changed:

我为较新的 Jetty 插件 jetty-maven-plugin (v8.0.0.M2) 找到了一个完全不同的文档,看起来配置名称已更改:

http://wiki.eclipse.org/Jetty/Reference/webdefault.xml#Using_the_Jetty_Maven_Plugin

http://wiki.eclipse.org/Jetty/Reference/webdefault.xml#Using_the_Jetty_Maven_Plugin

<project>
    ...
    <plugins>
        <plugin>
            ...
            <artifactId>jetty-maven-plugin</artifactId>
            <configuration>
                <webAppConfig>
                  ...
                  <defaultsDescriptor>/my/path/to/webdefault.xml</defaultsDescriptor>
                </webAppConfig>
            </configuration>
        </plugin>
        ...
    </plugins>
    ...
</project>

This now seems to work for the newer plugin. I'm still unsure why the v6 plugin does not pick up the customized config.

这现在似乎适用于较新的插件。我仍然不确定为什么 v6 插件没有选择自定义配置。

回答by wytten

The only solution I found that worked with maven-jetty-plugin 6.1.24 was this: http://false.ekta.is/2010/12/jettyrun-maven-plugin-file-locking-on-windows-a-better-way/

我发现与 maven-jetty-plugin 6.1.24 一起使用的唯一解决方案是:http: //false.ekta.is/2010/12/jettyrun-maven-plugin-file-locking-on-windows-a-better -道路/

回答by guymac

The Jetty documentation outlines three ways to do it (as of Jetty 9):

Jetty 文档概述了三种方法(从 Jetty 9 开始):

https://www.eclipse.org/jetty/documentation/current/troubleshooting-locked-files-on-windows.html

https://www.eclipse.org/jetty/documentation/current/troubleshooting-locked-files-on-windows.html

I successfully used the init-param method in Maven:

我在 Maven 中成功使用了 init-param 方法:

        <!-- Running an embedded server for testing/development -->
        <plugin>
            <groupId>org.eclipse.jetty</groupId>
            <artifactId>jetty-maven-plugin</artifactId>
            <version>9.4.9.v20180320</version>

            <configuration>
                <webApp>
                    <_initParams>
                        <org.eclipse.jetty.servlet.Default.useFileMappedBuffer>false</org.eclipse.jetty.servlet.Default.useFileMappedBuffer>
                    </_initParams>
                </webApp>
            </configuration>

        </plugin>