【maven】【idea】通过maven指定JDK版本
发布时间:2026/11/3 9:10:21 锦皓数字建站

文章目录一、问题描述二、解决方式1. 简单地说2. pom配置一、问题描述如图设置了通过idea设置了jdk的版本之后运行 maven build或者过一段时间之后项目的编译 jdk 版本会回到 1.5 版本再次修改还是回到1.5版本。二、解决方式This error means that you must not modify the project structure and build configuration like project dependencies, compiler settings, sources/resources directories etc using IDE UI dialogs. Instead, you must do corresponding changes in the Maven pom.xml file.Because otherwise you will loose all such changes made in IDE UI after the project fill be Reloaded by the IDE from the maven build files (pom.xml).1. 简单地说Maven使用的默认Java编译器版本是Java 1.5。为了使Maven使用Java编译器的较新版本编译Java代码需要在项目的POM文件pom.xml中显式指定Java编译器。2. pom配置在项目的父pom下添加插件!--通过maven设置jdk的版本 防止idea设置jdk版本之后--buildpluginManagementpluginsplugingroupIdorg.apache.maven.plugins/groupIdartifactIdmaven-compiler-plugin/artifactIdversion3.10.1/versionconfigurationsource1.8/sourcetarget1.8/targetencodingUTF-8/encoding/configuration/plugin/plugins/pluginManagement/build参考https://blog.csdn.net/tgvincent/article/details/118089774
锦
锦皓数字建站
深耕本土企业品牌数字化升级,专注原创端正雅致商务官网,从视觉设计到稳定运维全程保驾护航。