我刚刚用Spring Boot安装了一个新的GraphQL Java工具应用程序。Maven pom.xml文件中的精确版本是:
com.graphql-java-kickstart:graphql-spring-boot-starter:12.0.0com.graphql-java-kickstart:graphiql-spring-boot-starter:11.1.0com.graphql-java-kickstart:graphql-java-tools:12.0.0尽管我的应用程序会编译,但当我启动Spring应用程序时,它会失败,并出现以下神秘错误:
***************************
APPLICATION FAILED TO START
***************************
Description:
An attempt was made to call a method that does not exist. The attempt was made from the following location:
graphql.kickstart.tools.resolver.FieldResolverScanner.findResolverMethod(FieldResolverScanner.kt:92)
The following method did not exist:
'java.lang.String kotlin.text.CharsKt.titlecase(char)'
The method's class, kotlin.text.CharsKt, is available from the following locations:
jar:file:/C:/Users/c-martind/.m2/repository/org/jetbrains/kotlin/kotlin-stdlib/1.3.61/kotlin-stdlib-1.3.61.jar!/kotlin/text/CharsKt.class
It was loaded from the following location:
file:/C:/Users/c-martind/.m2/repository/org/jetbrains/kotlin/kotlin-stdlib/1.3.61/kotlin-stdlib-1.3.61.jar
Action:
Correct the classpath of your application so that it contains a single, compatible version of kotlin.text.CharsKt我使用的是Java而不是Kotlin,所以我不知道为什么它与Kotlin有问题。
发布于 2021-10-08 21:14:38
按照GraphQL Java工具的自述,您需要在Maven pom.xml文件中的<properties>部分中设置Kotlin版本:
<properties>
<kotlin.version>1.5.0</kotlin.version>
</properties>如果您在Spring中使用graphl-java-tools,您可能会遇到Kotlin版本不匹配的情况,因为两者都依赖于Kotlin。具体来说,Spring可以用低于GraphQL Java所要求的版本覆盖版本。设置上面的属性会将Kotlin版本提升到适当的版本。如果不覆盖此版本,您将遇到类似于NoClassDefFoundError的错误,或者在应用程序启动期间遇到的错误。
https://stackoverflow.com/questions/69501764
复制相似问题