idea中运行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

解决:maven默认环境为jdk,只需要改如下即可:
在IDEA中,打开File | Settings | Build, Execution, Deployment | Build Tools | Maven | Runner在VM Options中
添加-Dfile.encoding=GBK,切记一定是GBK。即使用UTF-8的话,依然是乱码,这是因为Maven的默认平台编码是GBK,
如果你在命令行中输入mvn -version的话,会得到如下信息,根据Default locale可以看出

 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
IDEA使用Maven构建的Spring Boot项目出现乱码问题,你可以尝试以下解决方法: 1. 修改IDEA的默认编码设置: - 打开IDEA,点击菜单栏的 "File" -> "Settings"。 - 在弹出的设置窗口,选择 "Editor" -> "File Encodings"。 - 将 "IDE Encoding"、"Project Encoding" 和 "Default encoding for properties files" 都设置为 "UTF-8"。 - 点击 "OK" 按钮保存并关闭设置窗口。 2. 修改Maven编译插件的编码配置: - 打开项目的pom.xml文件。 - 在`<build>`标签下添加以下配置: ```xml <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> ``` - 保存pom.xml文件并重新构建项目。 3. 修改Spring Boot应用程序的配置文件编码: - 打开Spring Boot应用程序的配置文件(例如application.properties或application.yml)。 - 确保配置文件的所有文本都使用UTF-8编码保存。 - 如果是使用.properties文件,确保文件头部添加以下注释行: ```properties # encoding=UTF-8 ``` - 如果是使用.yml文件,确保文件头部添加以下注释行: ```yaml # encoding: UTF-8 ``` - 保存配置文件并重新启动应用程序。 4. 检查控制台输出的编码: - 确保你正在使用支持UTF-8编码的控制台,例如在IDEA,可以点击控制台窗口右上角的设置按钮,选择 "UTF-8" 编码。 通过以上操作,你的Spring Boot应用程序在IDEA控制台应该能够正确显示文字符了。如果问题仍然存在,请尝试重启IDEA或重新导入项目,并确保所有相关文件都使用UTF-8编码保存。 希望这些解决方法对你有所帮助!如果有任何疑问,请随时提问。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值