fai*_*gir 7 java spring spring-boot graphql graphql-java
我最近开始使用graphql它并发现它非常有趣。由于大多数我的rest应用程序都在java,我决定做一个快速安装使用所提供的春天开机启动的项目graphql-java团队。它带有graph-iqlautoconf 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
Run Code Online (Sandbox Code Playgroud)
这是我的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
Run Code Online (Sandbox Code Playgroud)
运行后gradle build,我jar从终端运行生成的文件。这是我在本地主机上得到的:
我在使用 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
| 归档时间: |
|
| 查看次数: |
6000 次 |
| 最近记录: |