首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用GraphQL工具时,Spring应用程序启动失败

使用GraphQL工具时,Spring应用程序启动失败
EN

Stack Overflow用户
提问于 2021-10-08 21:14:38
回答 1查看 1K关注 0票数 0

我刚刚用Spring Boot安装了一个新的GraphQL Java工具应用程序。Maven pom.xml文件中的精确版本是:

  • com.graphql-java-kickstart:graphql-spring-boot-starter:12.0.0
  • com.graphql-java-kickstart:graphiql-spring-boot-starter:11.1.0
  • com.graphql-java-kickstart:graphql-java-tools:12.0.0

尽管我的应用程序会编译,但当我启动Spring应用程序时,它会失败,并出现以下神秘错误:

代码语言:javascript
复制
***************************
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有问题。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-10-08 21:14:38

按照GraphQL Java工具的自述,您需要在Maven pom.xml文件中的<properties>部分中设置Kotlin版本:

代码语言:javascript
复制
<properties>
    <kotlin.version>1.5.0</kotlin.version>
</properties>

如果您在Spring中使用graphl-java-tools,您可能会遇到Kotlin版本不匹配的情况,因为两者都依赖于Kotlin。具体来说,Spring可以用低于GraphQL Java所要求的版本覆盖版本。设置上面的属性会将Kotlin版本提升到适当的版本。如果不覆盖此版本,您将遇到类似于NoClassDefFoundError的错误,或者在应用程序启动期间遇到的错误。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/69501764

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档