原帖:
我想过滤在web.xmlJetty 8.1 servlet 容器上运行的 Java 6 Web 应用程序的部署描述符,但到目前为止它不起作用。我想根据活动的 Maven 配置文件设置不同的 JSF 项目阶段:
<context-param>
    <param-name>javax.faces.PROJECT_STAGE</param-name>
    <param-value>${jsfProjectStage}</param-value>
</context-param>
中的配置文件部分pom.xml如下所示:
<profiles>
    <profile>
        <id>development</id>
        <activation>
            <activeByDefault>true</activeByDefault>
        </activation>
        <properties>
            <jsfProjectStage>Development</jsfProjectStage>
        </properties>
    </profile>
    <profile>
        <id>production</id>
        <properties>
            <jsfProjectStage>Production</jsfProjectStage>
        </properties>
    </profile>
</profiles>
在 Internet 上,您可以找到几种方法来实现这一点,例如使用替代的 web.xml 文件。但对我来说,最明显的方法似乎是使用 maven-war-plugin:
<build>
    <finalName>...</finalName>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <version>2.3</version>
            <configuration>
                <webResources>
                    <webResource>
                        <directory>src/main/webapp/WEB-INF</directory>
                        <filtering>true</filtering>
                        <targetPath>WEB-INF</targetPath>
                        <includes>
                            <include>web.xml</include>
                        </includes>
                    </webResource>
                </webResources>
            </configuration>
        </plugin>
        ...
    </plugins>
</build>
由于您找到了许多带有此代码片段的答案或文章,我想知道为什么它对我不起作用。我尝试替换<webResource>为<resource>(经常以这种方式找到)并且我也尝试添加<filteringDeploymentDescriptors>true</filteringDeploymentDescriptors>但没有任何效果。
有谁知道,为了正确过滤 web.xml,这里缺少什么?还是我必须明确指定<filters>?
谢谢塞巴斯蒂安
_
更新:
感谢user944849,我现在知道我未过滤的原因web.xml不是 maven-war-plugin 而是 jetty-maven-plugin,因为我曾经mvn jetty:run运行(未组装的)webapp。有谁知道如何web.xml在运行未组装的 webapp 之前使用 jetty-maven-plugin 过滤?