maven编译控制台中文乱码问题解决

乱码现象:

"C:\Program Files\Java\jdk-10.0.2\bin\java.exe" -Dmaven.multiModuleProjectDirectory=H:\maven_web -Dmaven.home=H:\Maven\apache-maven-3.5.2 -Dclassworlds.conf=H:\Maven\apache-maven-3.5.2\bin\m2.conf "-javaagent:H:\idea\IntelliJ IDEA 2018.3\lib\idea_rt.jar=54564:H:\idea\IntelliJ IDEA 2018.3\bin" -Dfile.encoding=UTF-8 -classpath H:\Maven\apache-maven-3.5.2\boot\plexus-classworlds-2.5.2.jar org.codehaus.classworlds.Launcher -Didea.version=2018.3 tomcat:run
[INFO] Scanning for projects...
[INFO] 
[INFO] ------------------------------------------------------------------------
[INFO] Building maven_web Maven Webapp 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] >>> tomcat-maven-plugin:1.1:run (default-cli) > compile @ maven_web >>>
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ maven_web ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory H:\maven_web\src\main\resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ maven_web ---
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent!
[INFO] Compiling 1 source file to H:\maven_web\target\classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
[ERROR] ����֧��Դѡ�� 5����ʹ�� 6 ����߰汾��
[ERROR] ����֧��Ŀ��ѡ�� 1.5����ʹ�� 1.6 ����߰汾��
[INFO] 2 errors 
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.172 s
[INFO] Finished at: 2019-06-23T22:32:27+08:00
[INFO] Final Memory: 12M/50M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project maven_web: Compilation failure: Compilation failure: 
[ERROR] ����֧��Դѡ�� 5����ʹ�� 6 ����߰汾��
[ERROR] ����֧��Ŀ��ѡ�� 1.5����ʹ�� 1.6 ����߰汾��
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

Process finished with exit code 1

原因:idea编码格式为utf-8;Maven的默认平台编码是GBK,
在命令行中输入mvn -version的话,会得到如下信息,根据Default locale可以看出:

解決方法:

File | Settings | Build, Execution, Deployment | Build Tools | Maven | Runner在VM Options中
添加-Dfile.encoding=GBK即可。

发布了91 篇原创文章 · 获赞 11 · 访问量 2万+

猜你喜欢

转载自blog.csdn.net/hjing123/article/details/103382636
今日推荐