解决Intellij IDEA maven 自动设置JDK为JDK1.5

解决方法:

  1. maven项目pom文件中指定编译的jdk版本(项目指定)
bash 复制代码
<properties>
	<maven.compiler.source>1.8</maven.compiler.source>
	<maven.compiler.target>1.8</maven.compiler.target>
</properties>
  1. maven-compiler-plugin 插件指定当前项目编译的jdk版本
bash 复制代码
<build>
	<plugins>
		<plugin>
			<groupId>org.apache.maven.plugins</groupId>
			<artifactId>maven-compiler-plugin</artifactId>
			<version>2.3.2</version>
			<configuration>
				<source>1.8</source>
				<target>1.8</target>
			</configuration>
		</plugin>
	</plugins>
</build>
  1. SpringBoot项目,只需指定java.version即可
bash 复制代码
<properties>
	<java.version>1.8</java.version>
</properties>
  1. maven 全局jdk版本(针对idea配置的本地maven)
    在本地maven目录下conf文件夹内的setting.xml配置文件中加入以下配置
bash 复制代码
<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>
相关推荐
都叫我大帅哥25 分钟前
🌊 Redis Stream深度探险:从秒杀系统到面试通关
java·redis
都叫我大帅哥26 分钟前
Redis持久化全解析:从健忘症患者到记忆大师的逆袭
java·redis
程序猿阿越1 小时前
Kafka源码(一)Controller选举与创建Topic
java·后端·源码
程序无bug1 小时前
Spring6 当中 Bean 的生命周期的详细解析:有五步,有七步,有十步
java
二川bro1 小时前
飞算智造JavaAI:智能编程革命——AI重构Java开发新范式
java·人工智能·重构
Q_970956391 小时前
java+vue+SpringBoo校园失物招领网站(程序+数据库+报告+部署教程+答辩指导)
java·数据库·vue.js
Wyc724091 小时前
Maven
java·数据库·maven
程序猿小D1 小时前
[附源码+数据库+毕业论文]基于Spring+MyBatis+MySQL+Maven+jsp实现的电影小说网站管理系统,推荐!
java·数据库·mysql·spring·毕业设计·ssm框架·电影小说网站
木头没有瓜3 小时前
idea离线安装插件
java·ide·intellij-idea