现在我们基本上编码使用utf-8编码,如果是中文环境下,可能本地操作系统是gbk,所以会产生中文乱码。
第一步:设置idea的编码格式
idea 安装目录下/bin/idea.exe.vmoptions 和/bin/idea64.exe.vmoptions 下添加-Dfile.encoding=utf-8 保证idea的java 虚拟机环境时utf-8编码
第二步:统一设置我们代码的编码格式
在 idea下 file -> setting -> editor -> file encodings -> global encoding ,project encoding及properties的编码设置为utf-8
第三步:重启idea
第四步:通过idea启动进程时传递jVM arg 保证需要启动的进程的编码环境为utf-8 ,这麽说可能有些抽象,比如 通过idea运行的tomcat ,mvn pluggings ,及test等进程的编码环境.
run -> edit config -> vm option 添加-Dfile.encoding=utf-8