栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

Intellij IDEA--解决乱码/设置JDK版本--方法

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

Intellij IDEA--解决乱码/设置JDK版本--方法

原文网址:Intellij IDEA--解决乱码/设置JDK版本--方法_IT利刃出鞘的博客-CSDN博客

简介

        本文介绍如何解决IDEA乱码的问题以及如何设置JDK的版本。

乱码问题 工程乱码

File=> Settings=> Editor=> File Encodings=>    (下方三处全都改为UTF-8)
        Global Encoding
        Project Encoding
        Default encoding for properties files

控制台或日志文件 乱码

法1:修改整个Idea的JVM参数(推荐)

    Help=> Edit Custom VM Options=> 添加一行:-Dfile.encoding=UTF-8

法2:修改工程的JVM参数(有时候不管用)

    Run=> Edit Configurations=> 

  • SpringBoot项目:Configuration=> Environment=> VM Options=> 填入“-Dfile.encoding=UTF-8”
  • Application项目:Configuration=> VM Options=> 填入“-Dfile.encoding=UTF-8”
  • Tomcat项目:Server=> VM Options=> 填入“-Dfile.encoding=UTF-8”

法3:修改编译参数(不推荐)

        File=> Settings=> Build,Execution,Deployment=> Compiler=> Java Compiler=>
                  Additional command line parameters=>填入:-encoding utf-8

统一jdk版本 第1步:配置JDK环境变量

装好JDK之后,要添加一个环境变量:JAVA_HOME:

第2步:修改Idea配置

1.设置编译及构建工具的JDK版本

File=> Setting=> Build,Execution,Deployment=>
        Complier=> Java Compiler=> Per-module bytecode version=> Target bytecode version
        Build Tools=>
                Maven=>
                        importing=> JDK for importer
                        Runner=> JRE
                Gradle=>
                        Gradle JVM

2.设置项目和模块的JDK版本

File=> Project Structure=> Project Settings=>
        Project=> Project SDK
        Modules=> Dependencies=> Module SDK
        Modules=> Modules=> Sources=> Language level

3.设置平台的JDK版本

File=> Project Structure=> Platform Settings=> SDKs

4.设置运行时的JDK版本

Run=> Edit Configurations=> Run/Debug Configurations
        若应用为 SpringBoot:Configuration=> JRE=> 选择正确的JRE
        若应用为 Application:Build and run=> 选择正确的JDK

5.pom.xml

解决Language Level和Java Compiler版本自动被重置问题


    
        
            org.apache.maven.plugins
            maven-compiler-plugin
            3.5.1
            
            
                8
                8
            
        
    

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/952334.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号