[英]spring boot starter graphql not working
I recently started working with graphql
and found it very intriguing. 我最近开始使用
graphql
,发现它非常有趣。 Since most of my rest
apps were in java
, I decided to do a quick setup using the provided spring boot starter project by the graphql-java
team. 由于我的大多数
rest
应用程序都是使用java
,我决定使用graphql-java
团队提供的spring boot starter项目进行快速设置。 It comes with graph-iql
autoconf spring setup, which makes it easier to query /graphql
endpoint. 它带有
graph-iql
autoconf spring设置,可以更容易地查询/graphql
端点。
After spending a few good hours on the project setup in IDEA, I was able to run the graphql-sample-app . 在IDEA的项目设置上花了几个小时后,我能够运行graphql-sample-app 。 But I think my servlet is still not enabled, and only the
graphiql
endpoint is running, as the default query is returning 404
. 但我认为我的servlet仍然没有启用,只有
graphiql
端点正在运行,因为默认查询返回404
。
This is application.yml
: 这是
application.yml
:
spring:
application:
name: graphql-todo-app
server:
port: 9000
graphql:
spring-graphql-common:
clientMutationIdName: clientMutationId
injectClientMutationId: true
allowEmptyClientMutationId: false
mutationInputArgumentName: input
outputObjectNamePrefix: Payload
inputObjectNamePrefix: Input
schemaMutationObjectName: Mutation
servlet:
mapping: /graphql
enabled: true
corsEnabled: true
graphiql:
mapping: /graphiql
enabled: true
This is what my build.gradle
file looks like: 这是我的
build.gradle
文件的样子:
buildscript {
repositories {
maven { url "https://plugins.gradle.org/m2/" }
maven { url 'http://repo.spring.io/plugins-release' }
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:1.5.2.RELEASE")
classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:1.6"
}
}
apply plugin: 'java'
apply plugin: 'org.springframework.boot'
repositories {
jcenter()
mavenCentral()
}
dependencies{
// compile(project(":graphql-spring-boot-starter"))
// compile(project(":graphiql-spring-boot-starter"))
compile 'com.graphql-java:graphql-spring-boot-starter:3.6.0'
// to embed GraphiQL tool
compile 'com.graphql-java:graphiql-spring-boot-starter:3.6.0'
compile "com.embedler.moon.graphql:spring-graphql-common:$LIB_SPRING_GRAPHQL_COMMON_VER"
compile("org.springframework.boot:spring-boot-starter-web")
compile("org.springframework.boot:spring-boot-starter-actuator")
testCompile("org.springframework.boot:spring-boot-starter-test")
}
jar.enabled = true
uploadArchives.enabled = false
bintrayUpload.enabled = false
After running gradle build
, I run the generated jar
file from the terminal. 运行
gradle build
,我从终端运行生成的jar
文件。 This is what I get on localhost: 这是我在localhost上得到的:
I had the same issue using Spring boot 2.0.0 (M6). 我使用Spring boot 2.0.0(M6)遇到了同样的问题。 Switching back to 1.5.8.RELEASE solved the problem.
切换回1.5.8.RELEASE解决了这个问题。 They're working on the issue, it will be released as soon as there is a non milestone release for Spring boot 2.x
他们正在解决这个问题,一旦Spring boot 2.x出现非里程碑版本,它就会被释放
https://github.com/graphql-java/graphql-spring-boot/issues/40 https://github.com/graphql-java/graphql-spring-boot/issues/40
https://github.com/graphql-java/graphql-spring-boot/pull/36 https://github.com/graphql-java/graphql-spring-boot/pull/36
更改为版本1.5.9.RELEASE的spring-boot-starter-stop,它对我有用
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.