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

2.2 修改MAVEN的配置
maven的配置文件在安裝目錄的setting.xml,需配置多個(gè)JDK的配置。
<profiles>里面配置多個(gè)JDK,<activeProfiles>里面負(fù)責(zé)切換配置。
如下方配置:
<?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>
<!-- 中央倉(cāng)庫(kù)在中國(guó)的鏡像 -->
<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>
<!-- 中央倉(cāng)庫(kù)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)模塊設(shè)置菜單。

(2)模塊設(shè)置jdk。

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

(4)重載maven

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

總結(jié)
以上為個(gè)人經(jīng)驗(yàn),希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。
相關(guān)文章
Log4j2?重大漏洞編譯好的log4j-2.15.0.jar包下載(替換過(guò)程)
Apache?開(kāi)源項(xiàng)目?Log4j?的遠(yuǎn)程代碼執(zhí)行漏洞細(xì)節(jié)被公開(kāi),由于?Log4j?的廣泛使用,該漏洞一旦被攻擊者利用會(huì)造成嚴(yán)重危害,下面小編給大家?guī)?lái)了Log4j2?重大漏洞編譯好的log4j-2.15.0.jar包下載,感興趣的朋友一起看看吧2021-12-12
詳解如何更改SpringBoot TomCat運(yùn)行方式
這篇文章主要介紹了詳解如何更改SpringBoot TomCat運(yùn)行方式,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2021-04-04
java中構(gòu)造器內(nèi)部調(diào)用構(gòu)造器實(shí)例詳解
在本篇文章里小編給大家分享的是關(guān)于java中構(gòu)造器內(nèi)部調(diào)用構(gòu)造器實(shí)例內(nèi)容,需要的朋友們可以學(xué)習(xí)下。2020-05-05
springboot整合shiro多驗(yàn)證登錄功能的實(shí)現(xiàn)(賬號(hào)密碼登錄和使用手機(jī)驗(yàn)證碼登錄)
這篇文章給大家介紹springboot整合shiro多驗(yàn)證登錄功能的實(shí)現(xiàn)方法,包括賬號(hào)密碼登錄和使用手機(jī)驗(yàn)證碼登錄功能,本文通過(guò)實(shí)例代碼給大家介紹的非常詳細(xì),需要的朋友參考下吧2021-07-07

