为什么Maven surefire-report-plugin会创建错误消息"此平台不支持字符编码$ {outputEncoding}"?

时间:2014-09-18 05:49:53

标签: java maven maven-surefire-plugin

我也配置了maven surefire-report-plugin:

<plugin>
   <groupId>org.apache.maven.plugins</groupId>
   <artifactId>maven-surefire-report-plugin</artifactId>
   <version>2.17</version>
   <configuration>
        <outputDirectory>${myPath}</outputDirectory>
        <outputEncoding>UTF-8</outputEncoding>
   </configuration>
   <executions>
       <execution>
            <id>create-surefire-report</id>
            <phase>test</phase>  
            <goals>
                <goal>report</goal>
            </goals>
        </execution>                   
    </executions>              
</plugin>

以下是Maven-surefire-plugin的配置:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>2.16</version>
    <configuration>
        <testFailureIgnore>false</testFailureIgnore>                    
    </configuration>                
</plugin>

我该如何解决这个问题?在这种配置中应该改变什么?

谢谢!

1 个答案:

答案 0 :(得分:0)

  1. <outputEncoding>UTF-8</outputEncoding>
  2. 移除<configuration>
  3. <reporting>代码相同,定义<properties> outputEncoding就像这样

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    </properties>
    
    <reporting>
        <plugins>
            <plugin>
               ...
            </plugin>
        </plugins>
    </reporting>
    
  4. 注意:这适用于Maven 2.x&amp; Maven 3.x