在Maven War插件中进行过滤 [英] Filtering in Maven War Plugin

查看:150
本文介绍了在Maven War插件中进行过滤的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不了解Maven War插件的以下过滤器配置.有人可以向我解释一下,他们在做什么?我已经用第一个示例和第二个示例标记了代码

I don´t understand the following filter configuration for the maven war plugin. Could somebody explain me please, what they are doing? I have marked the code with First Example and Second Example

    <plugin>
            <artifactId>maven-war-plugin</artifactId>
            <configuration>
                <webResources>
                    <!--First Example-->
                    <resource>
                        <directory>/src/main/webapp</directory>
                        <filtering>true</filtering>
                        <includes>
                            <include>**/*.xml</include>
                            <include>**/*.xhtml</include>
                        </includes>
                    </resource>
                    <!--Second Example-->  
                    <resource>
                        <directory>${basedir}/src/main/webapp</directory>
                        <filtering>false</filtering>
                        <excludes>
                            <exclude>**/*.xml</exclude>
                            <exclude>**/*.xhtml</exclude>
                        </excludes>
                    </resource>
                </webResources>
            </configuration>
        </plugin>

推荐答案

我知道这是一个古老的问题,但另一个答案却极具误导性,以至于我觉得应该澄清一下...

I know this is kind of old question, but the other answer is so misleading that I felt I should clarify it...

过滤通常表示在处理的文本文件中用替换属性占位符的概念(例如,用项目的实际版本替换${project.version}的出现).

Filtering in Maven usually denotes a concept of substituting property placeholders in processed text files (e.g. replacing occurrences of ${project.version} with your project's actual version).

您的配置可以理解为:每个XML和/或XHTML文件在复制到目标目录时都应该进行属性替换,而其他所有内容都应简单地复制到目标目录中,而无需进行任何处理.

Your configuration can be read as: Every XML and/or XHTML file should undergo property substitution when copied to the target directory, while everything else should be simply copied to the target directory without any processing.

一些进一步的阅读:

  • filtering of resources
  • filtering of webapp resources
  • filtering of web.xml

这篇关于在Maven War插件中进行过滤的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆