[英]spring boot containing com.graphql-java and graphql-java-spring-boot-starter-webmvc
I have an issue with my springboot application which uses the below maven dependency for graphql:我的 springboot 应用程序存在问题,该应用程序使用 graphql 的以下 maven 依赖项:
<dependency>
<groupId>com.graphql-java-generator</groupId>
<artifactId>graphql-java-runtime</artifactId>
<version>${graphql-maven-plugin.version}</version>
</dependency>
I'm getting the below error in the logs:我在日志中收到以下错误:
Description:
Field graphQL in graphql.spring.web.servlet.components.DefaultGraphQLInvocation required a bean of type 'graphql.GraphQL' that could not be found.
The injection point has the following annotations:
- @org.springframework.beans.factory.annotation.Autowired(required=true)
Action:
Consider defining a bean of type 'graphql.GraphQL' in your configuration.
Any help will be very much appreciated.任何帮助将不胜感激。
Thanks!谢谢!
So finally I found out what the problem was;所以最后我发现了问题所在; 'com.graphql-java-generator' contains a spring-mvc application with it's own autowiring and components.
'com.graphql-java-generator' 包含一个带有自己的自动装配和组件的 spring-mvc 应用程序。 And (to me) it looks like there is a problem in the autowiring in that there is no proper bean defined for 'graphql.GraphQL' object as it is said in the error message.
而且(对我来说)看起来自动装配中存在问题,因为没有为“graphql.GraphQL”object 定义正确的 bean,如错误消息中所述。 So the solution was to remove that library from being included in the build:
所以解决方案是从构建中删除该库:
<dependency>
<groupId>com.graphql-java-generator</groupId>
<artifactId>graphql-java-runtime</artifactId>
<version>${graphql-maven-plugin.version}</version>
<exclusions>
<exclusion>
<groupId>com.graphql-java</groupId>
<artifactId>graphql-java-spring-boot-starter-webmvc</artifactId>
</exclusion>
</exclusions>
</dependency>
hope this helps someone who uses both spring boot and graphql-java together.希望这对同时使用 spring 引导和 graphql-java 的人有所帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.