Eclipse——执行Maven命令控制台乱码 Eclipse——执行Maven命令控制台乱码

摘要:本文主要记录了在Eclipse中执行Maven命令时,控制台出现乱码的问题,以及解决办法。

问题重现

在执行“mvn clean install”命令时,当执行到测试的代码时,控制台打印乱码:

1 Running com.bookstore.test.TestDB
2 ���� 01, 2020 4:50:34 ���� org.springframework.beans...
3 ��Ϣ: Loading XML bean definitions from class path resource [spring.xml]
4 ���� 01, 2020 4:50:34 ���� org.springframework.context...
5 ��Ϣ: Refreshing org.springframework.context...
6 ���� 01, 2020 4:50:34 ���� org.springframework.core...
7 ��Ϣ: Loading properties file from class path resource [jdbc.properties]

解决办法

在pom.xml文件中加入配置:

1 <properties>
2     <argLine>-Dfile.encoding=UTF-8</argLine>
3 </properties>