如何在过滤时覆盖jetty-maven-plugin中的web.xml

时间:2012-09-04 20:52:30

标签: java-ee maven jetty war maven-jetty-plugin

我的web.xml中有${properties}根据个人资料进行过滤。我想使用带有jetty的最终属性的web.xml:run但是我还没有成功,它总是坚持使用它的默认路径到web.xml,即file:/home/---/Projects/project/trunk/src/main/webapp/WEB-INF/web.xml

我试过了:

    <plugin>
        <groupId>org.mortbay.jetty</groupId>
        <artifactId>jetty-maven-plugin</artifactId>
        <version>8.1.4.v20120524</version>
        <configuration>
            <webAppConfig>
                <overrideDescriptor>target/project/WEB-INF/web.xml</overrideDescriptor>
            </webAppConfig>
        </configuration>
    </plugin>

    <plugin>
        <groupId>org.mortbay.jetty</groupId>
        <artifactId>jetty-maven-plugin</artifactId>
        <version>8.1.4.v20120524</version>
        <configuration>
            <overrideWebXml>target/project/WEB-INF/web.xml</overrideWebXml>
        </configuration>
    </plugin>

部分问题是知道哪些配置与哪个版本一起使用,因为似乎没有人写下来。此外,OverrideDescriptor仅根据eclipsepedia上的文档添加到Web上下文配置。

2 个答案:

答案 0 :(得分:3)

根据the documentation,配置选项为webXml

答案 1 :(得分:3)

接受的答案文档链接适用于Jetty 6,它不适用于OP的版本8.1.4.v20120524

对于上述版本,请使用this

    <plugins>
      <plugin>
        <groupId>org.mortbay.jetty</groupId>
        <artifactId>jetty-maven-plugin</artifactId>
        <version>8.1.4.v20120524</version>
        <configuration>
          <webApp>
            <descriptor>/path/to/web.xml</descriptor>
          </webApp>
        </configuration>
      </plugin>
    </plugins>