idea修改language level版本實現方式
1、前言
使用場景,當原本JDK1.8版本的編譯環(huán)境時,突然加載一個JDK17的項目時,項目reload或maven install時經常報錯language level版本問題,以下是解決方案。
2、操作步驟
2.1 修改系統環(huán)境變量
多個JDK為了方便切換,我的環(huán)境變量是這樣設置的,JAVA_HOME負責切換版本,Path變量就跟平時配置的一樣。
需要到哪個版本就切換JAVA_HOME里面的變量就行。

2.2 修改MAVEN的配置
maven的配置文件在安裝目錄的setting.xml,需配置多個JDK的配置。
<profiles>里面配置多個JDK,<activeProfiles>里面負責切換配置。
如下方配置:
<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.2.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.2.0 https://maven.apache.org/xsd/settings-1.2.0.xsd">
<pluginGroups>
</pluginGroups>
<proxies>
</proxies>
<servers>
</servers>
<mirrors>
<mirror>
<id>alimaven</id>
<name>aliyun maven</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
<mirrorOf>central</mirrorOf>
</mirror>
<mirror>
<id>aliyun</id>
<mirrorOf>central</mirrorOf>
<name>aliyun-public</name>
<url>https://maven.aliyun.com/repository/public/</url>
</mirror>
<mirror>
<id>aliyun-spring</id>
<mirrorOf>spring</mirrorOf>
<name>aliyun-spring</name>
<url>https://maven.aliyun.com/repository/spring</url>
</mirror>
<!-- 中央倉庫在中國的鏡像 -->
<mirror>
<id>maven.net.cn</id>
<name>one of the central mirrors in china</name>
<url>http://maven.net.cn/content/groups/public/</url>
<mirrorOf>central</mirrorOf>
</mirror>
<!-- 中央倉庫1 -->
<mirror>
<id>repo1</id>
<mirrorOf>central</mirrorOf>
<name>Human Readable Name for this Mirror.</name>
<url>https://repo1.maven.org/maven2/</url>
</mirror>
</mirrors>
<!-- 以下是JDK配置 -->
<profiles>
<profile>
<id>jdk-1.8</id>
<activation>
<activeByDefault>true</activeByDefault>
<jdk>1.8</jdk>
</activation>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>
</properties>
</profile>
<profile>
<id>jdk-17</id>
<activation>
<activeByDefault>true</activeByDefault>
<jdk>17</jdk>
</activation>
<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<maven.compiler.compilerVersion>17</maven.compiler.compilerVersion>
</properties>
</profile>
</profiles>
<activeProfiles>
<!-- <activeProfile>jdk-1.8</activeProfile>-->
<activeProfile>jdk-17</activeProfile>
</activeProfiles>
</settings>
2.3 idea配置修改
(1)模塊設置菜單。

(2)模塊設置jdk。

(3)idea設置:file->setting,把圖片中的修改為你要的JDK版本。

(4)重載maven

(5)校驗,跟(1)的步驟一樣進入model setting,如下圖所示:

總結
以上為個人經驗,希望能給大家一個參考,也希望大家多多支持腳本之家。
相關文章
Log4j2?重大漏洞編譯好的log4j-2.15.0.jar包下載(替換過程)
Apache?開源項目?Log4j?的遠程代碼執(zhí)行漏洞細節(jié)被公開,由于?Log4j?的廣泛使用,該漏洞一旦被攻擊者利用會造成嚴重危害,下面小編給大家?guī)砹薒og4j2?重大漏洞編譯好的log4j-2.15.0.jar包下載,感興趣的朋友一起看看吧2021-12-12
springboot整合shiro多驗證登錄功能的實現(賬號密碼登錄和使用手機驗證碼登錄)
這篇文章給大家介紹springboot整合shiro多驗證登錄功能的實現方法,包括賬號密碼登錄和使用手機驗證碼登錄功能,本文通過實例代碼給大家介紹的非常詳細,需要的朋友參考下吧2021-07-07

