问题描述:
使用eclipse运行maven项目时,控制台打印和swing界面出现中文乱码,修改了windows --> preferences下关于编码的设置选项,仍然没有效果。
解决方案:
修改maven项目下的pom.xml文件,添加 <encoding> utf8 </encoding>
,重新编译该项目,即可解决乱码问题。
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<!-- 新添加,解决编码问题 -->
<encoding>utf8</encoding>
</configuration>
</plugin>
</plugins>
</build>