精选文章 springboot集成graphql(一)

springboot集成graphql(一)

作者:禅剑一如 时间: 2019-11-05 04:12:41
禅剑一如 2019-11-05 04:12:41

背景:基于上篇springboot集成jooq继续

GraphQL Playgroundhttps://github.com/prisma-labs/graphql-playground/releases

一、pom.xml文件引入相关依赖


    com.graphql-java-kickstart
    graphql-spring-boot-starter
    5.10.0


    com.graphql-java
    graphql-java
    2019-10-31T04-37-48-0919e71



    com.graphql-java-kickstart
    graphiql-spring-boot-starter
    5.10.0


    com.graphql-java
    graphql-java-spring-boot-starter-webmvc
    2019-06-24T11-47-27-31ab4f9


二、配置文件修改

1. application.yml增加服务配置

server:
  port: 8088
  #指定项目服务路径
  servlet:
    context-path: /api/v1

2. 在资源文件夹src/main/resources目录下添加文件company.graphqls

schema {
    query: CompanyQuery
}
type CompanyQuery {
    companyById(id: ID): Company
}
type Company {
    id: ID
    name: String
    age: Int
    address: String
    salary: Float
    joinDate: String
}

三配置GraphQLProvider,注册GraphQL

package com.zsx.graphql;

import com.google.common.base.Charsets;
import com.google.common.io.Resources;
import graphql.GraphQL;
import graphql.schema.GraphQLSchema;
import graphql.schema.idl.RuntimeWiring;
import graphql.schema.idl.SchemaGenerator;
import graphql.schema.idl.SchemaParser;
import graphql.schema.idl.TypeDefinitionRegistry;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import java.io.IOException;
import java.net.URL;

import static graphql.schema.idl.TypeRuntimeWiring.newTypeWiring;

@Component
public class CompanyGraphQLProvider {

    private GraphQL graphQL;

    @Autowired
    private CompanyGraphQLDataFetchers graphQLDataFetchers;

    @Bean
    public GraphQL graphQL() {
        return graphQL;
    }

    @PostConstruct
    public void init() throws IOException {
        URL url = Resources.getResource("company.graphqls");
        String sdl = Resources.toString(url, Charsets.UTF_8);
        GraphQLSchema graphQLSchema = buildSchema(sdl);
        this.graphQL = GraphQL.newGraphQL(graphQLSchema).build();
    }

    private GraphQLSchema buildSchema(String sdl) {
        // TODO: we will create the schema here later
        TypeDefinitionRegistry typeRegistry = new SchemaParser().parse(sdl);
        RuntimeWiring runtimeWiring = buildWiring();
        SchemaGenerator schemaGenerator = new SchemaGenerator();
        return schemaGenerator.makeExecutableSchema(typeRegistry, runtimeWiring);
    }


    private RuntimeWiring buildWiring() {
        return RuntimeWiring.newRuntimeWiring()
                .type(newTypeWiring("CompanyQuery")
                        .dataFetcher("companyById", graphQLDataFetchers.getCompanyByIdDataFetcher()))
                .build();
    }

}

 

四、配置GraphQLDataFetchers

package com.zsx.graphql;

import com.zsx.entity.Company;
import com.zsx.service.CompanyService;
import graphql.schema.DataFetcher;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class CompanyGraphQLDataFetchers {

    @Autowired
    private CompanyService companyService;

    public DataFetcher getCompanyByIdDataFetcher() {
        List companies = companyService.getCompanies();
        return dataFetchingEnvironment -> {
            Long companyId  = Long.valueOf(dataFetchingEnvironment.getArgument("id"));
            return companies
                    .stream()
                    .filter(company -> company.getId().equals(companyId))
                    .findFirst()
                    .orElse(null);
        };
    }

}

五、编写业务接口

package com.zsx.service;

import com.zsx.entity.Company;

import java.util.List;

public interface CompanyService {

    List getCompanies();

}

六、编写业务实现

package com.zsx.service.impl;

import com.zsx.entity.Company;
import com.zsx.service.CompanyService;
import org.jooq.DSLContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CompanyServiceImpl implements CompanyService {

    @Autowired
    private DSLContext dslContext;

    private com.zsx.generator.jooq.tables.Company company = com.zsx.generator.jooq.tables.Company.COMPANY.as("company");
    

    @Override
    public List getCompanies() {
        return dslContext.selectFrom(company).fetch().into(Company.class);
    }

}

七、启动主程序

E:\jdk\jdk-13.0.1\bin\java.exe -XX:TieredStopAtLevel=1 -noverify -Dspring.output.ansi.enabled=always -Dcom.sun.management.jmxremote -Dspring.jmx.enabled=true -Dspring.liveBeansView.mbeanDomain -Dspring.application.admin.enabled=true "-javaagent:E:\JetBrains\IntelliJ IDEA 2019.2.3\lib\idea_rt.jar=65186:E:\JetBrains\IntelliJ IDEA 2019.2.3\bin" -Dfile.encoding=UTF-8 -classpath F:\IdeaProjects\postgres\target\classes;E:\maven\repository\org\springframework\boot\spring-boot-starter-web\2.2.0.RELEASE\spring-boot-starter-web-2.2.0.RELEASE.jar;E:\maven\repository\org\springframework\boot\spring-boot-starter\2.2.0.RELEASE\spring-boot-starter-2.2.0.RELEASE.jar;E:\maven\repository\org\springframework\boot\spring-boot-starter-logging\2.2.0.RELEASE\spring-boot-starter-logging-2.2.0.RELEASE.jar;E:\maven\repository\ch\qos\logback\logback-classic\1.2.3\logback-classic-1.2.3.jar;E:\maven\repository\ch\qos\logback\logback-core\1.2.3\logback-core-1.2.3.jar;E:\maven\repository\org\apache\logging\log4j\log4j-to-slf4j\2.12.1\log4j-to-slf4j-2.12.1.jar;E:\maven\repository\org\apache\logging\log4j\log4j-api\2.12.1\log4j-api-2.12.1.jar;E:\maven\repository\org\slf4j\jul-to-slf4j\1.7.28\jul-to-slf4j-1.7.28.jar;E:\maven\repository\jakarta\annotation\jakarta.annotation-api\1.3.5\jakarta.annotation-api-1.3.5.jar;E:\maven\repository\org\yaml\snakeyaml\1.25\snakeyaml-1.25.jar;E:\maven\repository\org\springframework\boot\spring-boot-starter-json\2.2.0.RELEASE\spring-boot-starter-json-2.2.0.RELEASE.jar;E:\maven\repository\com\fasterxml\jackson\core\jackson-databind\2.10.0\jackson-databind-2.10.0.jar;E:\maven\repository\com\fasterxml\jackson\core\jackson-annotations\2.10.0\jackson-annotations-2.10.0.jar;E:\maven\repository\com\fasterxml\jackson\core\jackson-core\2.10.0\jackson-core-2.10.0.jar;E:\maven\repository\com\fasterxml\jackson\datatype\jackson-datatype-jdk8\2.10.0\jackson-datatype-jdk8-2.10.0.jar;E:\maven\repository\com\fasterxml\jackson\datatype\jackson-datatype-jsr310\2.10.0\jackson-datatype-jsr310-2.10.0.jar;E:\maven\repository\com\fasterxml\jackson\module\jackson-module-parameter-names\2.10.0\jackson-module-parameter-names-2.10.0.jar;E:\maven\repository\org\springframework\boot\spring-boot-starter-tomcat\2.2.0.RELEASE\spring-boot-starter-tomcat-2.2.0.RELEASE.jar;E:\maven\repository\org\apache\tomcat\embed\tomcat-embed-core\9.0.27\tomcat-embed-core-9.0.27.jar;E:\maven\repository\org\apache\tomcat\embed\tomcat-embed-el\9.0.27\tomcat-embed-el-9.0.27.jar;E:\maven\repository\org\apache\tomcat\embed\tomcat-embed-websocket\9.0.27\tomcat-embed-websocket-9.0.27.jar;E:\maven\repository\org\springframework\boot\spring-boot-starter-validation\2.2.0.RELEASE\spring-boot-starter-validation-2.2.0.RELEASE.jar;E:\maven\repository\jakarta\validation\jakarta.validation-api\2.0.1\jakarta.validation-api-2.0.1.jar;E:\maven\repository\org\hibernate\validator\hibernate-validator\6.0.17.Final\hibernate-validator-6.0.17.Final.jar;E:\maven\repository\org\jboss\logging\jboss-logging\3.4.1.Final\jboss-logging-3.4.1.Final.jar;E:\maven\repository\com\fasterxml\classmate\1.5.0\classmate-1.5.0.jar;E:\maven\repository\org\springframework\spring-web\5.2.0.RELEASE\spring-web-5.2.0.RELEASE.jar;E:\maven\repository\org\springframework\spring-beans\5.2.0.RELEASE\spring-beans-5.2.0.RELEASE.jar;E:\maven\repository\org\springframework\spring-webmvc\5.2.0.RELEASE\spring-webmvc-5.2.0.RELEASE.jar;E:\maven\repository\org\springframework\spring-context\5.2.0.RELEASE\spring-context-5.2.0.RELEASE.jar;E:\maven\repository\org\springframework\spring-expression\5.2.0.RELEASE\spring-expression-5.2.0.RELEASE.jar;E:\maven\repository\jakarta\xml\bind\jakarta.xml.bind-api\2.3.2\jakarta.xml.bind-api-2.3.2.jar;E:\maven\repository\org\springframework\spring-core\5.2.0.RELEASE\spring-core-5.2.0.RELEASE.jar;E:\maven\repository\org\springframework\spring-jcl\5.2.0.RELEASE\spring-jcl-5.2.0.RELEASE.jar;E:\maven\repository\org\springframework\boot\spring-boot-starter-aop\2.2.0.RELEASE\spring-boot-starter-aop-2.2.0.RELEASE.jar;E:\maven\repository\org\springframework\spring-aop\5.2.0.RELEASE\spring-aop-5.2.0.RELEASE.jar;E:\maven\repository\org\aspectj\aspectjweaver\1.9.4\aspectjweaver-1.9.4.jar;E:\maven\repository\com\graphql-java-kickstart\graphiql-spring-boot-starter\5.10.0\graphiql-spring-boot-starter-5.10.0.jar;E:\maven\repository\com\graphql-java-kickstart\graphiql-spring-boot-autoconfigure\5.10.0\graphiql-spring-boot-autoconfigure-5.10.0.jar;E:\maven\repository\org\apache\commons\commons-text\1.1\commons-text-1.1.jar;E:\maven\repository\org\apache\commons\commons-lang3\3.9\commons-lang3-3.9.jar;E:\maven\repository\com\graphql-java-kickstart\graphql-spring-boot-starter\5.10.0\graphql-spring-boot-starter-5.10.0.jar;E:\maven\repository\com\graphql-java-kickstart\graphql-spring-boot-autoconfigure\5.10.0\graphql-spring-boot-autoconfigure-5.10.0.jar;E:\maven\repository\org\springframework\boot\spring-boot-starter-websocket\2.2.0.RELEASE\spring-boot-starter-websocket-2.2.0.RELEASE.jar;E:\maven\repository\org\springframework\spring-messaging\5.2.0.RELEASE\spring-messaging-5.2.0.RELEASE.jar;E:\maven\repository\org\springframework\spring-websocket\5.2.0.RELEASE\spring-websocket-5.2.0.RELEASE.jar;E:\maven\repository\org\springframework\boot\spring-boot-starter-actuator\2.2.0.RELEASE\spring-boot-starter-actuator-2.2.0.RELEASE.jar;E:\maven\repository\org\springframework\boot\spring-boot-actuator-autoconfigure\2.2.0.RELEASE\spring-boot-actuator-autoconfigure-2.2.0.RELEASE.jar;E:\maven\repository\org\springframework\boot\spring-boot-actuator\2.2.0.RELEASE\spring-boot-actuator-2.2.0.RELEASE.jar;E:\maven\repository\io\micrometer\micrometer-core\1.3.0\micrometer-core-1.3.0.jar;E:\maven\repository\org\hdrhistogram\HdrHistogram\2.1.11\HdrHistogram-2.1.11.jar;E:\maven\repository\org\latencyutils\LatencyUtils\2.0.3\LatencyUtils-2.0.3.jar;E:\maven\repository\com\graphql-java-kickstart\graphql-java-servlet\8.0.0\graphql-java-servlet-8.0.0.jar;E:\maven\repository\javax\servlet\javax.servlet-api\4.0.1\javax.servlet-api-4.0.1.jar;E:\maven\repository\javax\websocket\javax.websocket-api\1.1\javax.websocket-api-1.1.jar;E:\maven\repository\commons-io\commons-io\2.6\commons-io-2.6.jar;E:\maven\repository\com\graphql-java-kickstart\graphql-java-tools\5.6.1\graphql-java-tools-5.6.1.jar;E:\maven\repository\org\jetbrains\kotlin\kotlin-stdlib\1.3.50\kotlin-stdlib-1.3.50.jar;E:\maven\repository\org\jetbrains\kotlin\kotlin-stdlib-common\1.3.50\kotlin-stdlib-common-1.3.50.jar;E:\maven\repository\org\jetbrains\annotations\13.0\annotations-13.0.jar;E:\maven\repository\org\jetbrains\kotlin\kotlin-reflect\1.3.50\kotlin-reflect-1.3.50.jar;E:\maven\repository\org\jetbrains\kotlinx\kotlinx-coroutines-jdk8\1.3.2\kotlinx-coroutines-jdk8-1.3.2.jar;E:\maven\repository\org\jetbrains\kotlinx\kotlinx-coroutines-core\1.3.2\kotlinx-coroutines-core-1.3.2.jar;E:\maven\repository\org\jetbrains\kotlinx\kotlinx-coroutines-reactive\1.3.2\kotlinx-coroutines-reactive-1.3.2.jar;E:\maven\repository\com\fasterxml\jackson\module\jackson-module-kotlin\2.10.0\jackson-module-kotlin-2.10.0.jar;E:\maven\repository\com\esotericsoftware\reflectasm\1.11.9\reflectasm-1.11.9.jar;E:\maven\repository\com\graphql-java\graphql-java-spring-boot-starter-webmvc\2019-06-24T11-47-27-31ab4f9\graphql-java-spring-boot-starter-webmvc-2019-06-24T11-47-27-31ab4f9.jar;E:\maven\repository\org\springframework\boot\spring-boot-autoconfigure\2.2.0.RELEASE\spring-boot-autoconfigure-2.2.0.RELEASE.jar;E:\maven\repository\com\graphql-java\graphql-java-spring-webmvc\2019-06-24T11-47-27-31ab4f9\graphql-java-spring-webmvc-2019-06-24T11-47-27-31ab4f9.jar;E:\maven\repository\org\springframework\boot\spring-boot-starter-jooq\2.2.0.RELEASE\spring-boot-starter-jooq-2.2.0.RELEASE.jar;E:\maven\repository\org\springframework\boot\spring-boot-starter-jdbc\2.2.0.RELEASE\spring-boot-starter-jdbc-2.2.0.RELEASE.jar;E:\maven\repository\com\zaxxer\HikariCP\3.4.1\HikariCP-3.4.1.jar;E:\maven\repository\org\springframework\spring-jdbc\5.2.0.RELEASE\spring-jdbc-5.2.0.RELEASE.jar;E:\maven\repository\jakarta\activation\jakarta.activation-api\1.2.1\jakarta.activation-api-1.2.1.jar;E:\maven\repository\org\springframework\spring-tx\5.2.0.RELEASE\spring-tx-5.2.0.RELEASE.jar;E:\maven\repository\org\jooq\jooq\3.12.2\jooq-3.12.2.jar;E:\maven\repository\org\jooq\jooq-meta\3.12.2\jooq-meta-3.12.2.jar;E:\maven\repository\org\jooq\jooq-codegen\3.12.2\jooq-codegen-3.12.2.jar;E:\maven\repository\org\flywaydb\flyway-core\6.0.7\flyway-core-6.0.7.jar;E:\maven\repository\org\glassfish\jaxb\jaxb-core\2.3.0.1\jaxb-core-2.3.0.1.jar;E:\maven\repository\javax\xml\bind\jaxb-api\2.3.1\jaxb-api-2.3.1.jar;E:\maven\repository\javax\activation\javax.activation-api\1.2.0\javax.activation-api-1.2.0.jar;E:\maven\repository\org\glassfish\jaxb\txw2\2.3.2\txw2-2.3.2.jar;E:\maven\repository\com\sun\istack\istack-commons-runtime\3.0.5\istack-commons-runtime-3.0.5.jar;E:\maven\repository\com\sun\xml\bind\jaxb-impl\2.3.2\jaxb-impl-2.3.2.jar;E:\maven\repository\org\postgresql\postgresql\42.2.8\postgresql-42.2.8.jar;E:\maven\repository\com\alibaba\fastjson\1.2.62\fastjson-1.2.62.jar;E:\maven\repository\org\projectlombok\lombok\1.18.10\lombok-1.18.10.jar;E:\maven\repository\org\mybatis\spring\boot\mybatis-spring-boot-starter\2.1.1\mybatis-spring-boot-starter-2.1.1.jar;E:\maven\repository\org\mybatis\spring\boot\mybatis-spring-boot-autoconfigure\2.1.1\mybatis-spring-boot-autoconfigure-2.1.1.jar;E:\maven\repository\org\mybatis\mybatis\3.5.3\mybatis-3.5.3.jar;E:\maven\repository\org\mybatis\mybatis-spring\2.0.3\mybatis-spring-2.0.3.jar;E:\maven\repository\com\graphql-java\graphql-java\2019-10-31T04-37-48-0919e71\graphql-java-2019-10-31T04-37-48-0919e71.jar;E:\maven\repository\org\antlr\antlr4-runtime\4.7.2\antlr4-runtime-4.7.2.jar;E:\maven\repository\org\slf4j\slf4j-api\1.7.28\slf4j-api-1.7.28.jar;E:\maven\repository\com\graphql-java\java-dataloader\2.2.3\java-dataloader-2.2.3.jar;E:\maven\repository\org\reactivestreams\reactive-streams\1.0.3\reactive-streams-1.0.3.jar;E:\maven\repository\com\google\guava\guava\28.1-jre\guava-28.1-jre.jar;E:\maven\repository\com\google\guava\failureaccess\1.0.1\failureaccess-1.0.1.jar;E:\maven\repository\com\google\guava\listenablefuture\9999.0-empty-to-avoid-conflict-with-guava\listenablefuture-9999.0-empty-to-avoid-conflict-with-guava.jar;E:\maven\repository\com\google\code\findbugs\jsr305\3.0.2\jsr305-3.0.2.jar;E:\maven\repository\org\checkerframework\checker-qual\2.8.1\checker-qual-2.8.1.jar;E:\maven\repository\com\google\errorprone\error_prone_annotations\2.3.2\error_prone_annotations-2.3.2.jar;E:\maven\repository\com\google\j2objc\j2objc-annotations\1.3\j2objc-annotations-1.3.jar;E:\maven\repository\org\codehaus\mojo\animal-sniffer-annotations\1.18\animal-sniffer-annotations-1.18.jar;E:\maven\repository\org\springframework\boot\spring-boot-devtools\2.2.0.RELEASE\spring-boot-devtools-2.2.0.RELEASE.jar;E:\maven\repository\org\springframework\boot\spring-boot\2.2.0.RELEASE\spring-boot-2.2.0.RELEASE.jar com.zsx.PostgresApplication
Java HotSpot(TM) 64-Bit Server VM warning: Options -Xverify:none and -noverify were deprecated in JDK 13 and will likely be removed in a future release.

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v2.2.0.RELEASE)

2019-11-05 16:05:15.846  INFO 12960 --- [  restartedMain] com.zsx.PostgresApplication              : Starting PostgresApplication on DESKTOP-I29QKRP with PID 12960 (F:\IdeaProjects\postgres\target\classes started by 18273 in F:\IdeaProjects\postgres)
2019-11-05 16:05:15.848  INFO 12960 --- [  restartedMain] com.zsx.PostgresApplication              : No active profile set, falling back to default profiles: default
2019-11-05 16:05:15.883  INFO 12960 --- [  restartedMain] o.s.b.devtools.restart.ChangeableUrls    : The Class-Path manifest attribute in E:\maven\repository\org\glassfish\jaxb\jaxb-core\2.3.0.1\jaxb-core-2.3.0.1.jar referenced one or more files that do not exist: file:/E:/maven/repository/org/glassfish/jaxb/jaxb-core/2.3.0.1/jaxb-api-2.3.0.jar,file:/E:/maven/repository/org/glassfish/jaxb/jaxb-core/2.3.0.1/txw2-2.3.0.1.jar,file:/E:/maven/repository/org/glassfish/jaxb/jaxb-core/2.3.0.1/istack-commons-runtime-3.0.5.jar
2019-11-05 16:05:15.883  INFO 12960 --- [  restartedMain] o.s.b.devtools.restart.ChangeableUrls    : The Class-Path manifest attribute in E:\maven\repository\com\sun\xml\bind\jaxb-impl\2.3.2\jaxb-impl-2.3.2.jar referenced one or more files that do not exist: file:/E:/maven/repository/com/sun/xml/bind/jaxb-impl/2.3.2/jaxb-runtime-2.3.2.jar,file:/E:/maven/repository/com/sun/xml/bind/jaxb-impl/2.3.2/txw2-2.3.2.jar,file:/E:/maven/repository/com/sun/xml/bind/jaxb-impl/2.3.2/istack-commons-runtime-3.0.8.jar,file:/E:/maven/repository/com/sun/xml/bind/jaxb-impl/2.3.2/stax-ex-1.8.1.jar,file:/E:/maven/repository/com/sun/xml/bind/jaxb-impl/2.3.2/FastInfoset-1.2.16.jar,file:/E:/maven/repository/com/sun/xml/bind/jaxb-impl/2.3.2/jakarta.activation-api-1.2.1.jar
2019-11-05 16:05:15.883  INFO 12960 --- [  restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : Devtools property defaults active! Set 'spring.devtools.add-properties' to 'false' to disable
2019-11-05 16:05:15.883  INFO 12960 --- [  restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : For additional web related logging consider setting the 'logging.level.web' property to 'DEBUG'
2019-11-05 16:05:16.565  INFO 12960 --- [  restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2019-11-05 16:05:16.762  INFO 12960 --- [  restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8088 (http)
2019-11-05 16:05:16.767  INFO 12960 --- [  restartedMain] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2019-11-05 16:05:16.767  INFO 12960 --- [  restartedMain] org.apache.catalina.core.StandardEngine  : Starting Servlet engine: [Apache Tomcat/9.0.27]
2019-11-05 16:05:16.811  INFO 12960 --- [  restartedMain] o.a.c.c.C.[.[localhost].[/api/v1]        : Initializing Spring embedded WebApplicationContext
2019-11-05 16:05:16.811  INFO 12960 --- [  restartedMain] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 928 ms
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.jooq.tools.reflect.Reflect (file:/E:/maven/repository/org/jooq/jooq/3.12.2/jooq-3.12.2.jar) to constructor java.lang.invoke.MethodHandles$Lookup(java.lang.Class)
WARNING: Please consider reporting this to the maintainers of org.jooq.tools.reflect.Reflect
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
2019-11-05 16:05:17.197  WARN 12960 --- [  restartedMain] com.zaxxer.hikari.HikariConfig           : HikariPool-1 - idleTimeout has been set but has no effect because the pool is operating as a fixed size pool.
2019-11-05 16:05:17.197  INFO 12960 --- [  restartedMain] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Starting...
2019-11-05 16:05:17.246  INFO 12960 --- [  restartedMain] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Start completed.
2019-11-05 16:05:17.859  INFO 12960 --- [  restartedMain] o.s.s.concurrent.ThreadPoolTaskExecutor  : Initializing ExecutorService 'applicationTaskExecutor'
2019-11-05 16:05:18.050  INFO 12960 --- [  restartedMain] o.f.c.internal.license.VersionPrinter    : Flyway Community Edition 6.0.7 by Redgate
2019-11-05 16:05:18.055  INFO 12960 --- [  restartedMain] o.f.c.internal.database.DatabaseFactory  : Database: jdbc:postgresql://127.0.0.1:5432/mydb10 (PostgreSQL 12.0)
2019-11-05 16:05:18.068  INFO 12960 --- [  restartedMain] o.f.core.internal.command.DbValidate     : Successfully validated 2 migrations (execution time 00:00.008s)
2019-11-05 16:05:18.071  INFO 12960 --- [  restartedMain] o.f.core.internal.command.DbMigrate      : Current version of schema "myschema": 3
2019-11-05 16:05:18.071  INFO 12960 --- [  restartedMain] o.f.core.internal.command.DbMigrate      : Schema "myschema" is up to date. No migration necessary.
2019-11-05 16:05:18.129  INFO 12960 --- [  restartedMain] o.s.b.d.a.OptionalLiveReloadServer       : LiveReload server is running on port 35729
2019-11-05 16:05:18.132  INFO 12960 --- [  restartedMain] o.s.b.a.e.web.EndpointLinksResolver      : Exposing 2 endpoint(s) beneath base path '/actuator'
2019-11-05 16:05:18.293  INFO 12960 --- [  restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8088 (http) with context path '/api/v1'
2019-11-05 16:05:18.294  INFO 12960 --- [  restartedMain] com.zsx.PostgresApplication              : Started PostgresApplication in 2.649 seconds (JVM running for 3.131)
2019-11-05 16:05:18.585  INFO 12960 --- [3)-192.168.56.1] o.a.c.c.C.[.[localhost].[/api/v1]        : Initializing Spring DispatcherServlet 'dispatcherServlet'
2019-11-05 16:05:18.585  INFO 12960 --- [3)-192.168.56.1] o.s.web.servlet.DispatcherServlet        : Initializing Servlet 'dispatcherServlet'
2019-11-05 16:05:18.594  INFO 12960 --- [3)-192.168.56.1] o.s.web.servlet.DispatcherServlet        : Completed initialization in 9 ms

八、打开浏览器,查看请求:http://localhost:8088/api/v1/graphiql

springboot集成graphql(一)1

九、输入查询条件,查看查询结果

springboot集成graphql(一)2

从以上结果可以看出集成graphql成功

勿删,copyright占位
分享文章到微博
分享文章到朋友圈

上一篇:Fraction to Recurring Decimal

下一篇:接口自动化测试框架-httprunner V2.x中文使用手册-快速上手

您可能感兴趣

  • Spring Security 中的四种权限控制方式

    江南一点雨 公众号:江南一点雨,书《Spring boot+Vue实战》 9 人赞同了该文章 Spring Security 中对于权限控制默认已经提供了很多了,但是,一个优秀的框架必须具备良好的扩展性,恰好,Spring Security 的扩展性就非常棒,我们既可以使用 Spring Security 提供的方式做授权,也可以自定义授权逻辑。一句话,你想怎么玩都可以! 今天松哥来和大家介...

  • Spring Boot Starter依赖包及作用

    spring-boot-starter 这是Spring Boot的核心启动器,包含了自动配置、日志和YAML。 spring-boot-starter-amqp 通过spring-rabbit来支持AMQP协议(Advanced Message Queuing Protocol. 。 spring-boot-starter-aop 支持面向方面的编程即AOP,包括spring-aop和As...

  • Hasor Dataway使用教程

    绝了!这款工具让SpringBoot不再需要Controller、Service、DAO、Mapper! 来自:开源中国,作者:哈库纳 链接:https://my.oschina.net/ta8210/blog/3234639 Dataway介绍 Dataway 是基于 DataQL 服务聚合能力,为应用提供的一个接口配置工具,使得使用者无需开发任何代码就配置一个满足需求的接口。整个接口配置...

  • 【译】Spring Boot 2.0 官方迁移指南

    前提 希望本文档将帮助您把应用程序迁移到 Spring Boot 2.0。 在你开始之前 首先,Spring Boot 2.0 需要 Java 8 或更高版本。不再支持 Java 6 和 7 了。 在 Spring Boot 2.0 中,许多配置属性被重新命名/删除,开发人员需要更新application.properties/ application.yml相应的配置。为了帮助你解决这一问...

  • SpringCloud(1):SpringCloud介绍

    1.微服务介绍 1.1 什么是微服务? 微服务是一种架构风格,也是一种服务; 微服务的颗粒比较小,一个大型复杂软件应用由多个微服务组成,比如Netflix目前由500多个的微服务组成; 它采用UNIX设计的哲学,每种服务只做一件事,是一种松耦合的能够被独立开发和部署的无状态化服务(独立扩展、升级和可替换)。 1.2 微服务架构图 1.3 微服务的好处 技术异构性:在一个由多个服务相互协作的系...

  • SpringCloud系列使用Eureka进行服务治理

    1. 什么是微服务? “微服务”一词来自国外的一篇博文,网站:https://martinfowler.com/articles/microservices.html 如果您不能看懂英文文档,可以跳转到搜简体中文的文档 这是国人翻译的文档,可以学习参考: 引用官方文档解释: 简单来说,微服务架构风格[1]是一种将一个单一应用程序开发为一组小型服务的方法,每个服务运行在自己的进程中,服务间通信...

  • 分布式- Mysql + Mongo多数据源的分布式事务回滚

    1. XA两阶段提交模型 如上图,XA规范实现的两阶段提交流程:(下面全部翻译自XA规范原文) 阶段1:   TM要求所有RMs准备提交(或准备)事务分支。这询问RM是否能够保证提交事务分支的能力。RM可能会查询该RM内部的其他实例。CRM被要求准备它们创建的事务分支,将prepare请求发送到远程站点并接收结果。在返回失败并回滚其工作之后,RM可以丢弃事务分支的信息。 阶段2:   TM根...

  • SpringBoot启动类和核心注解

    标注@SpringBootApplication注解的类,就是Spring Boot应用程序的启动类。这个启动类中包含main方 法。 Spring BootiS过SpringApplication这个类的run方法来加载这个类,运行Spring Boot应用。 run方法做了两件事: 创建SpringApplication对象;在对象初始化时保存事件监听器,容器初始化类以及判断是否为web...

华为云40多款云服务产品0元试用活动

免费套餐,马上领取!
CSDN

CSDN

中国开发者社区CSDN (Chinese Software Developer Network) 创立于1999年,致力为中国开发者提供知识传播、在线学习、职业发展等全生命周期服务。