Java NoClassDefFoundError:graphql/execution/instrumentation/SimpleInstrumentation(graphql和Spring引导)

Java NoClassDefFoundError:graphql/execution/instrumentation/SimpleInstrumentation(graphql和Spring引导),java,spring-boot,graphql,Java,Spring Boot,Graphql,我正在试验GraphQL和Spring引导,当我尝试运行一个GraphQL查询时,我得到了下一个错误:(Graphiql加载良好顺便说一句) java.lang.NoClassDefFoundError:graphql/execution/instrumentation/SimpleInstrumentation POM依赖项: <dependency> <groupId>com.graphql-java</groupId> &

我正在试验GraphQL和Spring引导,当我尝试运行一个GraphQL查询时,我得到了下一个错误:(Graphiql加载良好顺便说一句)

java.lang.NoClassDefFoundError:graphql/execution/instrumentation/SimpleInstrumentation

POM依赖项:

<dependency>
        <groupId>com.graphql-java</groupId>
        <artifactId>graphql-spring-boot-starter</artifactId>
        <version>5.0.2</version>
    </dependency>
    <dependency>
        <groupId>com.graphql-java</groupId>
        <artifactId>graphql-java-tools</artifactId>
        <version>4.3.0</version>
    </dependency>
    <dependency>
        <groupId>com.graphql-java</groupId>
        <artifactId>graphiql-spring-boot-starter</artifactId>
        <version>4.0.0</version>
</dependency>

graphql-spring-boot-starter
graphql-java工具
都将在引擎盖下包含
graphql-java
。它们现在都包含不同的版本

一个包括6.0,另一个包括9.2。6.0以某种方式生效,这是一个非常旧的版本,
SimpleInstrumentation
在此版本之后添加,因此发生了
NoClassDefFoundError

简单的答案是升级
graphql-spring-boot-starter
graphql-java-tools
的版本,以便它们使用相同版本的
graphql-java


您可以使用
mvn dependency:tree
检查包含哪个版本的
graphql java

您检查过SimpleInstrumentation类是否在一个依赖项中,并且所有依赖项都在生成路径上吗?是的,我检查过,但不在那里。看来我的问题是它们之间的依赖关系不兼容。需要检查版本是否正确。非常感谢你的评论,这给了我需要的线索。我认为如果你使用最新版本,你不应该有兼容性。您还应该检查graphql spring boot starter是否不包括graphql java工具,在这种情况下,您可能会遇到依赖项冲突,需要通过排除其中一个依赖项来解决。您好!这解决了我的问题。我将graphiql spring boot starter升级到5.0.2版,以匹配graphql spring boot starter,并修复了该问题。谢谢
java.lang.NoClassDefFoundError: graphql/execution/instrumentation/SimpleInstrumentation
at graphql.servlet.GraphQLQueryInvoker$Builder.lambda$new$0(GraphQLQueryInvoker.java:101) ~[graphql-java-servlet-6.1.2.jar:na]
at graphql.servlet.GraphQLQueryInvoker.getInstrumentation(GraphQLQueryInvoker.java:72) ~[graphql-java-servlet-6.1.2.jar:na]
at graphql.servlet.GraphQLQueryInvoker.newGraphQL(GraphQLQueryInvoker.java:57) ~[graphql-java-servlet-6.1.2.jar:na]
at graphql.servlet.GraphQLQueryInvoker.query(GraphQLQueryInvoker.java:92) ~[graphql-java-servlet-6.1.2.jar:na]
at graphql.servlet.GraphQLQueryInvoker.query(GraphQLQueryInvoker.java:88) ~[graphql-java-servlet-6.1.2.jar:na]
at graphql.servlet.GraphQLQueryInvoker.query(GraphQLQueryInvoker.java:39) ~[graphql-java-servlet-6.1.2.jar:na]
at graphql.servlet.AbstractGraphQLHttpServlet.query(AbstractGraphQLHttpServlet.java:265) [graphql-java-servlet-6.1.2.jar:na]
at graphql.servlet.AbstractGraphQLHttpServlet.lambda$new$2(AbstractGraphQLHttpServlet.java:183) [graphql-java-servlet-6.1.2.jar:na]
at graphql.servlet.AbstractGraphQLHttpServlet.doRequest(AbstractGraphQLHttpServlet.java:236) [graphql-java-servlet-6.1.2.jar:na]
at graphql.servlet.AbstractGraphQLHttpServlet.doRequestAsync(AbstractGraphQLHttpServlet.java:227) [graphql-java-servlet-6.1.2.jar:na]
at graphql.servlet.AbstractGraphQLHttpServlet.doPost(AbstractGraphQLHttpServlet.java:257) [graphql-java-servlet-6.1.2.jar:na]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:660) [tomcat-embed-core-9.0.26.jar:9.0.26]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:741) [tomcat-embed-core-9.0.26.jar:9.0.26]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231) [tomcat-embed-core-9.0.26.jar:9.0.26]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) [tomcat-embed-core-9.0.26.jar:9.0.26]
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53) [tomcat-embed-websocket-9.0.26.jar:9.0.26]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) [tomcat-embed-core-9.0.26.jar:9.0.26]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) [tomcat-embed-core-9.0.26.jar:9.0.26]
at org.springframework.web.filter.CorsFilter.doFilterInternal(CorsFilter.java:97) [spring-web-5.1.10.RELEASE.jar:5.1.10.RELEASE]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) [spring-web-5.1.10.RELEASE.jar:5.1.10.RELEASE]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) [tomcat-embed-core-9.0.26.jar:9.0.26]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) [tomcat-embed-core-9.0.26.jar:9.0.26]
at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100) [spring-web-5.1.10.RELEASE.jar:5.1.10.RELEASE]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) [spring-web-5.1.10.RELEASE.jar:5.1.10.RELEASE]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) [tomcat-embed-core-9.0.26.jar:9.0.26]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) [tomcat-embed-core-9.0.26.jar:9.0.26]
at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93) [spring-web-5.1.10.RELEASE.jar:5.1.10.RELEASE]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) [spring-web-5.1.10.RELEASE.jar:5.1.10.RELEASE]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) [tomcat-embed-core-9.0.26.jar:9.0.26]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) [tomcat-embed-core-9.0.26.jar:9.0.26]
at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:94) [spring-web-5.1.10.RELEASE.jar:5.1.10.RELEASE]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) [spring-web-5.1.10.RELEASE.jar:5.1.10.RELEASE]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) [tomcat-embed-core-9.0.26.jar:9.0.26]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) [tomcat-embed-core-9.0.26.jar:9.0.26]
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201) [spring-web-5.1.10.RELEASE.jar:5.1.10.RELEASE]
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119) [spring-web-5.1.10.RELEASE.jar:5.1.10.RELEASE]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) [tomcat-embed-core-9.0.26.jar:9.0.26]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) ....
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1135) [na:na]
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) [na:na]
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) [tomcat-embed-core-9.0.26.jar:9.0.26]
at java.base/java.lang.Thread.run(Thread.java:844) [na:na]
Caused by: java.lang.ClassNotFoundException: graphql.execution.instrumentation.SimpleInstrumentation
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:582) ~[na:na]
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:190) ~[na:na]
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:499) ~[na:na]
... 54 common frames omitted