mvn test中文乱码处理

mvn test执行测试的时候调用的实际是maven-surefire-plugin插件
因为mvn启动时会新建一个jvm进程,默认没有指定编码所以中文乱码了.
启动时`<argLine>-Dfile.encoding=UTF-8</argLine>` 配合 forkMode参数就
可以解决中文乱码的问题了.
```xml
<build>
<plugins>
<!-- 解决maven test命令时console出现中文乱码乱码 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.7.2</version>
<configuration>
<forkMode>once</forkMode>
<argLine>-Dfile.encoding=UTF-8</argLine>
<!-- <systemProperties> -->
<!-- <property> -->
<!-- <name>net.sourceforge.cobertura.datafile</name> -->
<!-- <value>target/cobertura/cobertura.ser</value> -->
<!-- </property> -->
<!-- </systemProperties> -->
</configuration>
</plugin>
</plugins>
</build>
```

### 引用
-----------------------------
- [eclipse-->run as --> maven test 中文乱码](http://blog.csdn.net/zhch152/article/details/39584053)

posted @ 2017-08-09 09:36  jiftle  阅读(2275)  评论(0编辑  收藏  举报