maven:无法识别的标签:' testResources'

时间:2017-10-30 09:03:10

标签: java maven

当我运行mvn资源时:testResources我获取

Non-parseable POM /home/ernst/Software/pom.xml: Unrecognised tag: 'testResources' 

问题似乎

<build>
<resources>
  <resource>
<directory>${resourceDir}</directory>
<filtering>true</filtering>
<includes>
  <!--include>octave/m/java-arithmetics/**/*.m</include-->
  <include>octave/octaverc</include>
  <include>octave/java.opts</include>
</includes>
  </resource>
</resources>

<testResources>
  <testResource>
<directory>${tstResourcesDir}</directory>
    <filtering>true</filtering>
    <includes>
     <include>*.rml</include>
</includes>
  </testResource>
<testResources>

<plugins>

只要我只有标签资源,一切都很好。 现在我添加了testResources,我遇到了问题。 资源插件配置如下:

<plugins>
 <plugin>
<groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-resources-plugin</artifactId>
    <version>3.0.2</version>
<configuration>
  <escapeString>\</escapeString> <!-- \${java.home} -> ${java.home} -->
      <!--nonFilteredFileExtensions>
        <nonFilteredFileExtension>pdf</nonFilteredFileExtension>
      </nonFilteredFileExtensions-->
  <!--outputDirectory>${basedir}/target/</outputDirectory-->
</configuration>
  </plugin>

我的印象是,这个问题与maven本身有关 不是关于资源插件,对吧? 我使用maven 3.5.0。

1 个答案:

答案 0 :(得分:1)

在我看来,您的XML无效:

  • 您没有关闭build元素
  • 您没有关闭testResources元素

我使用以下build部分对您的XML进行了一些更新并构建了项目:

<build>
    <resources>
        <resource>
            <directory>${resourceDir}</directory>
            <filtering>true</filtering>
            <includes>
                <!--include>octave/m/java-arithmetics/**/*.m</include-->
                <include>octave/octaverc</include>
                <include>octave/java.opts</include>
            </includes>
        </resource>
    </resources>
    <testResources>
        <testResource>
            <directory>${tstResourcesDir}</directory>
            <filtering>true</filtering>
            <includes>
                <include>*.rml</include>
            </includes>
        </testResource>
    </testResources>
</build>

它对我有用。希望它能为你服务:))