Unsupported major.minor version 51.0解决办法

文章讲述了在执行Maven构建时遇到的错误,具体是由于使用的Maven插件与环境中的JDK版本不匹配导致的。错误信息指出API不兼容问题,源于CleanMojo的加载失败。作者发现原因是项目环境使用的是JDK1.7,而插件可能需要更高版本,如JDK17。解决方法是更新或重新安装Linux上的JDK至正确版本。
摘要由CSDN通过智能技术生成

先看看我的报错截图

 

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  08:51 min
[INFO] Finished at: 2023-06-04T12:36:47+08:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-clean-plugin:3.2.0:clean (default-clean) on project chatgpt-juejin: Execution default-clean of goal org.apache.maven.plugins:maven-clean-plugin:3.2.0:clean failed: Unable to load the mojo 'clean' in the plugin 'org.apache.maven.plugins:maven-clean-plugin:3.2.0' due to an API incompatibility: org.codehaus.plexus.component.repository.exception.ComponentLookupException: org/apache/maven/plugins/clean/CleanMojo : Unsupported major.minor version 52.0
[ERROR] -----------------------------------------------------
[ERROR] realm =    plugin>org.apache.maven.plugins:maven-clean-plugin:3.2.0
[ERROR] strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
[ERROR] urls[0] = file:/root/.m2/repository/org/apache/maven/plugins/maven-clean-plugin/3.2.0/maven-clean-plugin-3.2.0.jar
[ERROR] urls[1] = file:/root/.m2/repository/org/apache/maven/shared/maven-shared-utils/3.3.4/maven-shared-utils-3.3.4.jar
[ERROR] urls[2] = file:/root/.m2/repository/commons-io/commons-io/2.6/commons-io-2.6.jar
[ERROR] urls[3] = file:/root/.m2/repository/org/codehaus/plexus/plexus-utils/1.1/plexus-utils-1.1.jar
[ERROR] Number of foreign imports: 1
[ERROR] import: Entry[import  from realm ClassRealm[maven.api, parent: null]]
[ERROR]
[ERROR] -----------------------------------------------------
[ERROR]
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.ap

走弯路:

面对这个问题,我排查思路是通过最下面的报错信息

即 : Failed to execute goal org.apache.maven.plugins:maven-clean-plugin:3.2.0:clean (default-clean) on project chatgpt-juejin: Execution default-clean of goal org.apache.maven.plugins:maven-clean-plugin:3.2.0:clean failed: Unable to load the mojo 'clean' in the plugin 'org.apache.maven.plugins:maven-clean-plugin:3.2.0' due to an API incompatibility: org.codehaus.plexus.component.repository.exception.ComponentLookupException: org/apache/maven/plugins/clean/CleanMojo : Unsupported major.minor version 52.0

导致找了半个小时问题,一直试图看我的maven或者maven插件是不是版本有问题,一直找不到问题。运维给我报错信息太片面了。仔细看上面的报错截图,这个才是完整的错误信息,我发现了cased by这个关键词

 这下不就问题找到了,其实发现问题,解决就容易了。

原因:项目环境和运行环境的JDK版本不同导致的

解决办法:重新安装了Linux上的jdk版本(运维把jdk17安装成了jdk1.7)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值