maven maven-surefire-plugin的乱码问题<转>
?
maven maven-surefire-plugin的乱码问题
?
今天项目中出现奇怪问题,在eclipse中直接运行TestNG时,全部都OK,但是执行mvn test时却失败.观察其输出日志,发现有乱码,怀疑是乱码导致.
最终在官网发现蛛丝马迹.
maven-surefire-plugin是运行mvn test时执行测试的插件,其有一个配置参数forkMode,默认为once,即表示每次运行test时,新建一个JVM进程运行所有test.这可能会导致乱码问题.首先将forkMode设置为never,即不新建.再运行mvn test,全部OK了.果然是这个问题!!
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
??? <parent>
??????? <groupId>com.sun.grizzly</groupId>
??????? <artifactId>grizzly-project</artifactId>
??????? <version>1.9.0-SNAPSHOT</version>
??????? <relativePath>pom.xml</relativePath>
??? </parent>
??? <modelVersion>4.0.0</modelVersion>
??? <groupId>com.sun.grizzly</groupId>
??? <artifactId>grizzly-framework</artifactId>
??? <version>${grizzly-version}</version>
??? <name>grizzly-framework</name>
??? <url>https://grizzly.dev.java.net</url>
??? <build>
??????? <plugins>
??????????? <plugin>
??????????????????????????? <groupId>org.codehaus.mojo</groupId>
??????????????????????????? <artifactId>cobertura-maven-plugin</artifactId>
??????????????????????????? <executions>
??????????????????????????????? <execution>
??????????????????????????????????? <goals>
??????????????????????????????????????? <goal>clean</goal>
??????????????????????????????????? </goals>
??????????????????????????????? </execution>
??????????????????????????? </executions>
??????????????????????? </plugin>
??????????????????????? <plugin>
??????????????????????????? <groupId>org.apache.maven.plugins</groupId>
??????????????????????????? <artifactId>maven-surefire-plugin</artifactId>
??????????????????????????? <configuration>
??????????????????????????????? <systemProperties>
??????????????????????????????????? <property>
??????????????????????????????????? <name>net.sourceforge.cobertura.datafile</name>
??????????????????????????????????? <value>target/cobertura/cobertura.ser</value>
??????????????????????????????????? </property>
??????????????????????????????? </systemProperties>
??????????????????????????? </configuration>
??????????????????????? </plugin>
??????? </plugins>
??? </build>
??? <reporting>
??????? <plugins>
??????????? <plugin>
??????????????????????????? <groupId>org.codehaus.mojo</groupId>
??????????????????????????? <artifactId>cobertura-maven-plugin</artifactId>
??????????????????????????? <version>2.1</version>
??????????????????????? </plugin>
??????????????????????????? <plugin>
??????????????????????????????? <groupId>org.apache.maven.plugins</groupId>
??????????????????????????????? <artifactId>maven-surefire-report-plugin</artifactId>
??????????????????????????????? <version>2.0</version>
??????????????????????????? </plugin>
??????????????????????????? <plugin>
??????????????????????????????? <groupId>org.apache.maven.plugins</groupId>
??????????????????????????????? <artifactId>maven-surefire-plugin</artifactId>
??????????????????????????????? <version>2.2</version>
??????????????????????????? </plugin>
??????? </plugins>
??? </reporting>
</project>
I put explicit version of the plugins. You can remove that to use the latest version.
?
本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/gongxinchang/archive/2009/12/29/5094712.aspx
?