当前位置: 首页 > 面试题库 >

Groovy 2.5.0给出了noclassdeffounderror用于方法调用转换

林君博
2023-03-14
问题内容

当我将项目从Groovy 2.4。*升级到Groovy 2.5.0时,使用Gradle进行编译时,它不会为org / codehaus / groovy /
ast / methodcalltransformation提供noclassdeffounderror。

在Groovy 2.4中工作正常。

在此处发布整个异常:

org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':compileGroovy'.
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:100)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:70)
        at org.gradle.api.internal.tasks.execution.OutputDirectoryCreatingTaskExecuter.execute(OutputDirectoryCreatingTaskExecuter.java:51)
        at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:62)
        at org.gradle.api.internal.tasks.execution.ResolveTaskOutputCachingStateExecuter.execute(ResolveTaskOutputCachingStateExecuter.java:54)
        at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:60)
        at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:97)
        at org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter.execute(CleanupStaleOutputsExecuter.java:87)
        at org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.java:52)
        at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)
        at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:54)
        at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
        at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:34)
        at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker$1.run(DefaultTaskGraphExecuter.java:248)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:199)
        at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110)
        at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:241)
        at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:230)
        at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.processTask(DefaultTaskPlanExecutor.java:123)
        at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.access$200(DefaultTaskPlanExecutor.java:79)
        at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:104)
        at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:98)
        at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.execute(DefaultTaskExecutionPlan.java:626)
        at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.executeWithTask(DefaultTaskExecutionPlan.java:581)
        at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.run(DefaultTaskPlanExecutor.java:98)
        at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
        at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
        at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
Caused by: java.lang.NoClassDefFoundError: org/codehaus/groovy/ast/MethodCallTransformation
        at org.gradle.api.internal.tasks.compile.ApiGroovyCompiler$1.<init>(ApiGroovyCompiler.java:117)
        at org.gradle.api.internal.tasks.compile.ApiGroovyCompiler.execute(ApiGroovyCompiler.java:117)
        at org.gradle.api.internal.tasks.compile.ApiGroovyCompiler.execute(ApiGroovyCompiler.java:56)
        at org.gradle.api.internal.tasks.compile.daemon.AbstractDaemonCompiler$CompilerRunnable.run(AbstractDaemonCompiler.java:87)
        at org.gradle.workers.internal.DefaultWorkerServer.execute(DefaultWorkerServer.java:36)
        at org.gradle.workers.internal.WorkerDaemonServer.execute(WorkerDaemonServer.java:46)
        at org.gradle.workers.internal.WorkerDaemonServer.execute(WorkerDaemonServer.java:30)
        at org.gradle.process.internal.worker.request.WorkerAction.run(WorkerAction.java:100)
        at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
        at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
        at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:146)
        at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:128)
        at org.gradle.internal.remote.internal.hub.MessageHub$Handler.run(MessageHub.java:404)
        ... 3 more
Caused by: java.lang.ClassNotFoundException: org.codehaus.groovy.ast.MethodCallTransformation
        ... 16 more

问题答案:

如果您还使用了Spring Boot,则以下解决方法可能会有所帮助

参考:spring-boot问题#13444:允许使用Groovy 2.5

我使用Gradle 4.8和Spring Boot
1.5.14,并且在将Groovy从2.4.15升级到2.5.0之后得到了相同的NoClassDefFoundError。

按照问题的建议进行操作后,它可以成功构建并且运行良好,

  1. io.spring.dependency-management插件添加到build.gradle

(我本人使用Spring Boot 1.5,Spring Boot 2也应该工作良好)

    plugins {
    id 'org.springframework.boot' version '1.5.14.RELEASE'
    id 'io.spring.dependency-management' version '1.0.5.RELEASE'
}
  1. 设置groovy.version2.5.0

    ext['groovy.version'] = '2.5.0'
    
  2. 建立并享受groovy 2.5!:)



 类似资料:
  • 原因:org.springframework.beans.beanInstantiationException:无法实例化[org.springframework.boot.web.servlet.FilterRegistrationBean]:工厂方法“Createyadayada Filter”引发异常;嵌套异常是org.springframework.beans.factory.beanDe

  • 我无法解决这个问题。我有一个应用程序。 用 使用以下注释的测试类: 更多的StackTrace: 原因:org.springframework.beans.beanInstantiationException:无法实例化[org.springframework.boot.web.servlet.FilterRegistrationBean]:工厂方法“Createyadayada Filter”引

  • 我得到的例外是:- 1)异常信息**************************************************************************************************异常类型:System.TypeInitializationException类型名称:ChoETL.choappSettings消息:“ChoETL.choappSett

  • 问题内容: 我有一个公共抽象类,并且我正在尝试使用该方法,因为我需要扩展我的抽象类的类中的信息。一个例子是这样的: 但是,IntelliJ报告此: 代码可以正常运行,但是以我的方式来说,在我的IDE中包含数十个错误警告是有点。误报会打乱我的工作流程。 为什么显示这些错误,我该怎么做才能看不到它们? 问题答案: 代码很好,但是在IntelliJ中是错误。 错误报告, 另一份。 甚至还有更多错误报告,

  • 在我的应用程序中,我将数据导出到JSON。但是,当我尝试导入JSON文件时,它会抛出一个错误,如下所示: E/flatter:[错误:flatter/shell/common/shell.cc(184)]省道错误:未处理的异常:NoSuchMethodError:对null调用了方法“[]”。接收方:null尝试调用:#0对象。noSuchMethod(dart:core/runtime/libo

  • 我试图通过静态编程语言教程从Freecode营,但有这个问题的参考。 IntelliJ抱怨说 未解决的引用:main()中sayHello()中的问候语 意外标记(使用';'分隔同一行的表达式),在"Hi"之后 似乎只有通过“=”才能为参数赋值,而不是“:”