pom.xml中添加plugin: 指定测试时的编码类型
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.5</version>
<configuration>
<forkMode>once</forkMode>
<argLine>-Dfile.encoding=UTF-8</argLine>
<includes>
<include>**/*Test.java</include>
</includes>
<excludes>
</excludes>
</configuration>
</plugin>