Search

Java - 使用 Maven + JUnit 測試時中文出現亂碼

2015-09-24 7:57 PM

若出現中文顯示為亂碼的情形

可直接在 pom.xml 加入編碼設定即可

程式碼範例
  1. <!-- Surefire test plugin -->
  2. <plugin>
  3. <groupId>org.apache.maven.plugins</groupId>
  4. <artifactId>maven-surefire-plugin</artifactId>
  5. <version>2.17</version>
  6. <!-- 預防使用 Maven test 時中文顯示為亂碼 -->
  7. <configuration>
  8. <argLine>-Dfile.encoding=UTF-8</argLine>
  9. </configuration>
  10. </plugin>
各項資料連結
Maven Surefire

No comments:

Post a Comment