天天看點

Intellij Idea亂碼解決方案都在這裡了

亂碼場景

使用Intellij Idea經常遇到亂碼問題,可以總結為以下幾類亂碼的場景。

1、工程代碼亂碼。

2、main方法運作,控制台亂碼。

3、tomcat運作,控制台亂碼。

解決方案

1、工程代碼亂碼
Settings > Editor > File Encodings > Global Encodings & Project Encodings 設定為:UTF-8。      
2、main方法運作,控制台亂碼
Settings > Build, Execution, Deployment > Compile > Java Compiler > Additional command line parameters > 設定為:-encoding utf-8。      
3、tomcat運作,控制台亂碼
Edit Configurations > Tomcat Server > server > VM options > 設定為:-Dfile.encoding=UTF-8。      
idea > bin > idea.exe.vmoptions或者idea64.exe.vmoptions配置檔案末尾添加:-Dfile.encoding=UTF-8。      

繼續閱讀