检查Maven资源中的未解析属性

检查Maven资源中的未解析属性,maven,resources,filtering,Maven,Resources,Filtering,在src/main/resources/hello.xml中给定以下属性 <test>${resolved.property}</test> <test>${unresolved.property}</test> 在完成mvn:resources筛选后,如果还有任何未解析的属性,如何验证?您可以在完成资源筛选后使用验证XML文件 该插件可以根据模式验证XML文件,甚至只需检查它们的格式是否正确(这足以验证XML文件不包含属性标记) 您可以这样声明

在src/main/resources/hello.xml中给定以下属性

<test>${resolved.property}</test>
<test>${unresolved.property}</test>
在完成mvn:resources筛选后,如果还有任何未解析的属性,如何验证?

您可以在完成资源筛选后使用验证XML文件

该插件可以根据模式验证XML文件,甚至只需检查它们的格式是否正确(这足以验证XML文件不包含属性标记)

您可以这样声明插件:

<plugin>
  <groupId>org.codehaus.mojo</groupId>
  <artifactId>xml-maven-plugin</artifactId>
  <executions>
    <execution>
      <phase>process-resources</phase>
      <goals>
        <goal>validate</goal>
      </goals>
    </execution>
  </executions>
  <configuration>
    <validationSets>
        <validationSet>
            <dir>... your xml dir ...</dir>
            <includes>
                <include>*.xml</include>
            </includes>
        </validationSet>
    </validationSets>
  </configuration>
</plugin>

org.codehaus.mojo
xml maven插件
过程资源
验证
... 您的xml目录。。。
*.xml
注意:
过程资源的使用在这里很重要,因为您希望确保在过滤资源之后运行验证

<plugin>
  <groupId>org.codehaus.mojo</groupId>
  <artifactId>xml-maven-plugin</artifactId>
  <executions>
    <execution>
      <phase>process-resources</phase>
      <goals>
        <goal>validate</goal>
      </goals>
    </execution>
  </executions>
  <configuration>
    <validationSets>
        <validationSet>
            <dir>... your xml dir ...</dir>
            <includes>
                <include>*.xml</include>
            </includes>
        </validationSet>
    </validationSets>
  </configuration>
</plugin>