运行gradle清洁生成时记录错误
java.lang.Exception: Unexpected exception, expected<org.springframework.web.client.HttpClientErrorException> but was<java.lang.NoSuchMethodError>
at org.junit.internal.runners.statements.ExpectException.evaluate(ExpectException.java:30)
at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:75)
at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:86)
at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:84)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:366)致因: kotlin.collections.MapsKt.createMapBuilder()Ljava/util/Map;:kotlin.reflect.jvm.internal.impl.descriptors.Visibilities.(Visibilities.kt:56) at kotlin.reflect.jvm.internal.impl.descriptors.Visibility.compareTo(Visibility.kt:23) at kotlin.reflect.jvm.internal.impl.descriptors.DescriptorVisibility.compareTo(DescriptorVisibility.kt:66)
build.gradle
buildscript {
ext.kotlin_version = '1.6.21' // Required for Kotlin integration
ext.spring_boot_version = '2.6.6'
repositories {
mavenCentral()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" // Required for Kotlin integration
classpath "org.jetbrains.kotlin:kotlin-allopen:$kotlin_version" // See https://kotlinlang.org/docs/reference/compiler-plugins.html#kotlin-spring-compiler-plugin
classpath "org.springframework.boot:spring-boot-gradle-plugin:$spring_boot_version"
}
}
apply plugin: 'idea'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
apply plugin: 'kotlin' // Required for Kotlin integration
apply plugin: "kotlin-spring" // See https://kotlinlang.org/docs/reference/compiler-plugins.html#kotlin-spring-compiler-plugin
apply plugin: "jacoco"
repositories {
mavenCentral()
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib:${kotlin_version}" // Required for Kotlin integration
implementation "org.jetbrains.kotlin:kotlin-reflect:${kotlin_version}"
// implementation 'org.springframework.boot:spring-boot-starter-parent:2.6.7'
implementation "org.springframework.boot:spring-boot-starter-web"
implementation "org.springframework.boot:spring-boot-starter-actuator"
implementation "org.springframework.boot:spring-boot-starter-jdbc"
testImplementation "org.springframework.boot:spring-boot-starter-test"
testImplementation 'com.github.tomakehurst:wiremock-standalone:2.27.2'
testImplementation 'info.cukes:cucumber-spring:1.2.6'
testImplementation 'info.cukes:cucumber-junit:1.2.6'
implementation 'com.google.code.gson:gson:2.9.0'
// end::tests[]
}发布于 2022-08-24 10:55:26
您一定是在使用Kotlin的旧版本,也许是1.3。某些依赖项导致代码使用此降级版本。请查看外部库,您将能够找到1.6.21和1.3.11版本的kotlin-stdlib。
MapKt.createMapBuilder存在于1.6版本中,而不是1.3版本中。
运行./gradlew appname:dependencies并查看哪些依赖项正在使用此依赖项。
会有这样的事情
kotlin-stdlib-1.6.21--->1.3.21 (或11或其他版本)
如果是这种情况,则需要查看依赖关系洞察力,以查看使用此prev版本的依赖项:即1.3。
您可以运行cd ~/.gradle/caches/modules-2/files-2.1
搜索此版本号:
grep -r "1.3.11"
在我的例子中,kotlin-stdlib的版本是1.3.11。
您将能够找到导致降级发生的依赖关系。
https://stackoverflow.com/questions/72175041
复制相似问题