idea修改language level版本实现方式
1、前言
使用场景,当原本JDK1.8版本的编译环境时,突然加载一个JDK17的项目时,项目reload或maven install时经常报错language level版本问题,以下是解决方案。
2、操作步骤
2.1 修改系统环境变量
多个JDK为了方便切换,我的环境变量是这样设置的,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 的远程代码执行漏洞细节被公开,由于 Log4j 的广泛使用,该漏洞一旦被攻击者利用会造成严重危害,下面小编给大家带来了Log4j2 重大漏洞编译好的log4j-2.15.0.jar包下载,感兴趣的朋友一起看看吧2021-12-12
springboot整合shiro多验证登录功能的实现(账号密码登录和使用手机验证码登录)
这篇文章给大家介绍springboot整合shiro多验证登录功能的实现方法,包括账号密码登录和使用手机验证码登录功能,本文通过实例代码给大家介绍的非常详细,需要的朋友参考下吧2021-07-07


最新评论