pom.xml 更新后自动修改jre为J2SE-1.5

每次更新Maven的pom.xml后自动修改jre为J2SE-1.5。

pom.xml 更新后自动修改jre为J2SE-1.5

然后Eclipse提示“构建路径指定执行环境 J2SE-1.5。工作空间中没有与此环境严格兼容的 JRE”和“The compiler compliance specified is 1.5 but a JRE 13 is used”。手动修改后。问题可以解决。但老改也不是个事。

pom.xml 更新后自动修改jre为J2SE-1.5

I. 解决方法一:手动配置maven默认jre

首先编辑 settings.xml 文件
修改第184行左右的 <profile> 部分为你需要的版本,这里以我的JDK1.13为例。/<profile>

<code><profile>
jdk-1.13
<activation>
<activebydefault>true/<activebydefault>
1.13
/<activation>
<properties>
<maven.compiler.source>1.13/<maven.compiler.source>
<maven.compiler.target>1.13/<maven.compiler.target>
<maven.compiler.compilerversion>1.13/<maven.compiler.compilerversion>
/<properties>
/<profile>/<code>
pom.xml 更新后自动修改jre为J2SE-1.5

II. 解决方法二:修改项目pom.xml文件

在项目的pom.xml文件中添加下面设置,jdk版本修改成需要的版本。

<code><build>
<plugins>
<plugin>
<groupid>org.apache.maven.plugins/<groupid>
<artifactid>maven-compiler-plugin/<artifactid>
<configuration>
<source>1.13/<source>
<target>1.13/<target>
/<configuration>
/<plugin>
/<plugins>
/<build>/<code>
pom.xml 更新后自动修改jre为J2SE-1.5

III. OK,搞定问题

pom.xml 更新后自动修改jre为J2SE-1.5


分享到:


相關文章: