Seb*_* S. 5 web.xml java-ee maven maven-jetty-plugin
原始帖子:
 
我想过滤在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>
在互联网上,您可以找到几种方法来实现这一目标,例如使用备用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过滤?
在确定问题不是maven-war-plugin而是jetty-maven-plugin之后,我只需要将maven命令更改为mvn clean jetty:runto mvn clean jetty:run-war,以便在嵌入式jetty上运行已组装的webapp,部署描述符也会在其中运行过滤.
谢谢你帮助
塞巴斯蒂安
| 归档时间: | 
 | 
| 查看次数: | 3465 次 | 
| 最近记录: |