原因:java.lang.NoClassDefFoundError:无法初始化类com.jayway.restassured.RestAssured

vkrams:

我正在尝试设置最新版本的Spring Cloud Contract。但是它总是抛出异常,无法初始化。我的摇篮看起来像这样。我可以在外部库中看到2.9.0是可见的。

dependencies {
    classpath "org.springframework.boot:spring-boot-gradle-plugin:2.0.0.M7"
    classpath "org.springframework.cloud:spring-cloud-contract-gradle-plugin:1.2.2.RELEASE"
    classpath "com.jayway.restassured:rest-assured:2.9.0"
    classpath "com.jayway.restassured:spring-mock-mvc:2.9.0"
}

dependencyManagement {
imports {
    mavenBom "org.springframework.cloud:spring-cloud-dependencies:Edgware.RELEASE"
 }
}
testCompile ("com.jayway.restassured:rest-assured:2.9.0")
        {
            force = true
        }
testCompile ("com.jayway.restassured:spring-mock-mvc:2.9.0")
        {
            force = true
        }

这是例外:

org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':generateContractTests'.
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.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:58)
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:625)
at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.executeWithTask(DefaultTaskExecutionPlan.java:580)
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: Could not initialize class com.jayway.restassured.RestAssured
at org.springframework.cloud.contract.verifier.builder.ClassPresenceChecker.isClassPresent(JavaTestGenerator.groovy:191)
at org.springframework.cloud.contract.verifier.builder.ClassPresenceChecker$isClassPresent.call(Unknown Source)
at org.springframework.cloud.contract.verifier.builder.JavaTestGenerator.buildClass(JavaTestGenerator.groovy:72)
at org.springframework.cloud.contract.verifier.builder.SingleTestGenerator$buildClass.call(Unknown Source)
at org.springframework.cloud.contract.verifier.TestGenerator.processIncludedDirectory(TestGenerator.groovy:118)
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.springframework.cloud.contract.verifier.TestGenerator$_generateTestClasses_closure1.doCall(TestGenerator.groovy:100)
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.springframework.cloud.contract.verifier.TestGenerator.generateTestClasses(TestGenerator.groovy:99)
at org.springframework.cloud.contract.verifier.TestGenerator.generate(TestGenerator.groovy:81)
at org.springframework.cloud.contract.verifier.TestGenerator$generate.call(Unknown Source)
at org.springframework.cloud.contract.verifier.plugin.GenerateServerTestsTask.generate(GenerateServerTestsTask.groovy:65)
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.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73)
at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.doExecute(DefaultTaskClassInfoStore.java:142)
at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.execute(DefaultTaskClassInfoStore.java:135)
at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.execute(DefaultTaskClassInfoStore.java:122)
at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:762)
at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:729)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$1.run(ExecuteActionsTaskExecuter.java:121)
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.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:110)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:92)
... 28 more

请帮助我解决此问题。

Marcin Grzejszczak:

Spring Cloud Contract 1.2.x与Boot不兼容2.0.0请使用Spring Cloud Contract 2.0.x您正在使用Edgware与Spring Boot 2.0不兼容BOM。请使用FinchleyBOM。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

java.lang.NoClassDefFoundError:无法初始化类org.powermock.modules.junit4.rule.PowerMockRule

java.lang.NoClassDefFoundError:无法初始化类javax.media.jai.JAI

java.lang.NoClassDefFoundError:无法初始化类org.bytedeco.javacpp.avutil

RestAssured_Class未找到_com / github / fge / jsonschema / main / JsonSchemaFactory

java.lang.NoClassDefFoundError:io / restassured / path / json / mapper / factory / JsonbObjectMapperFactory

RestAssured和无记名令牌

java.lang.NoClassDefFoundError:无法初始化类java.awt.Toolkit

java.lang.NoClassDefFoundError:无法初始化类XXX

使用Java RestAssured创建POST请求,返回状态码422

JUnit + Mockito或RestAssured

无法解析导入io.restassured.RestAssured

RestAssured:如何检查json数组响应的长度?

java.lang.NoClassDefFoundError:无法初始化类xxx.xxx.xxx.HibernateUtil

春季:java.lang.NoClassDefFoundError:无法初始化类

如何在同一个项目中初始化多个RestAssured url而又不会互相覆盖?

java.lang.NoClassDefFoundError:无法初始化com.datastax.driver.core.Cluster类

ARM64计算机上的Cassandra启动失败(java.lang.NoClassDefFoundError:无法初始化com.sun.jna.Native类)

Zeppelin java.lang.NoClassDefFoundError:无法初始化类org.apache.spark.rdd.RDDOperationScope $

关于java.lang.NoClassDefFoundError:无法初始化类org.xerial.snappy.Snappy

java.lang.NoClassDefFoundError:无法初始化com.googlecode.objectify.ObjectifyService类

Corda-无法初始化主类胶囊(引起原因:java.lang.NoClassDefFoundError:java / lang / instrument / Instrumentation)

原因:java.lang.NoClassDefFoundError:无法初始化类javassist.util.proxy.DefineClassHelper

如何将RestAssured响应转换为Java列表

mapGroupsWithState引发错误原因:java.lang.NoClassDefFoundError:无法初始化

java.lang.NoClassDefFoundError:无法初始化类org.springframework.mail.javamail.SmartMimeMessage

java.lang.NoClassDefFoundError:无法初始化类sun.nio.ch.FileChannelImpl

Grails域类单元测试,约束设置问题-java.lang.NoClassDefFoundError:无法初始化

java.lang.NoClassDefFoundError:无法初始化类org.apache.commons.logging.LogFactory

线程“主”中的异常java.lang.NoClassDefFoundError无法初始化类org.bytedeco.javacpp.avutil