gpt4 book ai didi

java - spring boot 启动器 graphql 不工作

转载 作者:塔克拉玛干 更新时间:2023-11-02 19:49:48 25 4
gpt4 key购买 nike

我最近开始使用 graphql 并发现它非常有趣。由于我的大部分 rest 应用程序都在 java 中,我决定使用提供的 spring boot starter 进行快速设置。 graphql-java 团队的项目。它带有 graph-iql autoconf spring 设置,这使得查询 /graphql 端点更容易。

在 IDEA 中花了几个小时进行项目设置后,我能够运行 graphql-sample-app .但我认为我的 servlet 仍未启用,只有 graphiql 端点正在运行,因为默认查询返回 404

这是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

这是我的 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

运行 gradle build 后,我从终端运行生成的 jar 文件。这是我在本地主机上得到的:

enter image description here

最佳答案

我在使用 Spring boot 2.0.0 (M6) 时遇到了同样的问题。切换回 1.5.8.RELEASE 解决了这个问题。他们正在解决这个问题,一旦有 Spring boot 2.x 的非里程碑版本就会发布

https://github.com/graphql-java/graphql-spring-boot/issues/40

https://github.com/graphql-java/graphql-spring-boot/pull/36

关于java - spring boot 启动器 graphql 不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45522750/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com