构建SpringFox时遇AbstractMethodError错误,求解决方法
解决SpringFox构建时的AbstractMethodError问题
问题现象
克隆springfox仓库后,执行构建命令:
./gradlew clean build -i
持续抛出AbstractMethodError错误,具体错误信息如下:
* What went wrong: Receiver class org.ajoberstar.grgit.operation.OpenOp does not define or inherit an implementation of the resolved method abstract setProperty(Ljava/lang/String;Ljava/lang/Object;)V of interface groovy.lang.GroovyObject. * Exception is: java.lang.AbstractMethodError: Receiver class org.ajoberstar.grgit.operation.OpenOp does not define or inherit an implementation of the resolved method abstract setProperty(Ljava/lang/String;Ljava/lang/Object;)V of interface groovy.lang.GroovyObject. at org.ajoberstar.grgit.internal.OpSyntax$_mapOperation_closure1.doCall(OpSyntax.groovy:17) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at com.sun.proxy.$Proxy84.accept(Unknown Source) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at org.ajoberstar.grgit.internal.OpSyntax.mapOperation(OpSyntax.groovy:16) at org.ajoberstar.grgit.internal.OpSyntax$mapOperation.callStatic(Unknown Source) at org.ajoberstar.grgit.Grgit.open(Grgit.groovy) at org.ajoberstar.grgit.Grgit$open.call(Unknown Source) at org.ajoberstar.grgit.gradle.GrgitPlugin.apply(GrgitPlugin.groovy:17) at org.ajoberstar.grgit.gradle.GrgitPlugin.apply(GrgitPlugin.groovy)
当前环境
- Java版本:
java version "11.0.19" 2023-04-18 LTS Java(TM) SE Runtime Environment 18.9 (build 11.0.19+9-LTS-224) Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.19+9-LTS-224, mixed mode)
- Gradle版本:gradle-6.5
- build.gradle中配置的插件:
id "org.ajoberstar.grgit" version "4.0.2" id "org.ajoberstar.git-publish" version "3.0.0-rc.1"
有效解决办法
该错误源于Grgit插件版本与Gradle自带的Groovy依赖不兼容,以下是几种可行的修复方案:
方案1:降级Grgit插件版本
将Grgit及git-publish插件降级到与Gradle 6.5兼容的版本,修改build.gradle中的插件配置:
id "org.ajoberstar.grgit" version "3.2.0" id "org.ajoberstar.git-publish" version "2.1.3"
降级后的插件版本与Gradle 6.5的Groovy版本匹配度更高,可规避方法实现不兼容问题。
方案2:升级Gradle版本
将Gradle版本升级到6.9.x系列稳定版(如6.9.4),新版本Gradle对Groovy依赖做了适配,可兼容Grgit 4.x插件。修改项目根目录下gradle/wrapper/gradle-wrapper.properties文件:
distributionUrl=https\://services.gradle.org/distributions/gradle-6.9.4-bin.zip
修改后重新执行构建命令即可。
方案3:临时禁用Grgit插件
如果不需要Git相关的构建功能,可临时注释掉build.gradle中的Grgit插件配置:
// id "org.ajoberstar.grgit" version "4.0.2" // id "org.ajoberstar.git-publish" version "3.0.0-rc.1"
跳过插件加载环节后可直接完成项目构建。
内容的提问来源于stack exchange,提问作者Sash_KP
相关产品推荐
相关产品推荐

