解决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>
相关推荐
阿巴斯甜1 分钟前
int sum = list.stream().reduce(0, Integer::sum); 含义?
java
阿巴斯甜2 分钟前
Stream 的使用:
java
Foreer黑爷6 分钟前
Java并发工具箱:CountDownLatch与CyclicBarrier使用指南
java·开发语言·jvm
lwf0061649 分钟前
Maven Wrapper 使用指南
maven
亦暖筑序13 分钟前
Spring AI Alibaba + RAG 实战:知识库检索模块从设计到落地
java·开源
MeAT ITEM18 分钟前
ShardingSphere-jdbc 5.5.0 + spring boot 基础配置 - 实战篇
java·spring boot·后端
ekuoleung20 分钟前
Spring Boot 3.4 + Java 21 在量化平台中的架构实践
java·架构
Black蜡笔小新30 分钟前
国标GB28181视频监控平台EasyCVR赋能平安乡村建设,构筑乡村治理“数字防线”
java·网络·音视频
蚰蜒螟33 分钟前
从 pthread_create 到 thread_native_entry:glibc 如何唤醒 Java 线程
java·开发语言
callJJ1 小时前
JVM 类加载机制详解——从 .class 文件到对象诞生的完整旅程
java·jvm·类加载·双亲委派模型