IDEA版本:12.1.4
在系統中運行main方法System.out.println()中文是沒有問題的,
但是就是在運行Maven的test過程中,所有的中文輸出都會是有亂碼
網上搜索了一下,試了兩個方法都是沒有作用的
首先就是IDEA啓動參數,12後都是默認爲UTF-8了,然後就是我的項目文件編碼也是默認爲UTF-8了,
後來改了一下POM文件,中文輸出成功:
<procejt>
...
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<forkMode>once</forkMode>
<argLine>-Dfile.encoding=UTF-8</argLine>
</configuration>
</plugin>
</plugins>
</build>
...
</procejt>
如果在Maven啓動了服務器出現亂碼,可以指定服務器配置中得VM options 爲:
-Dfile.encoding=UTF-8
不過這個我沒有試,不知道有效果沒有。