Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/flash/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
有没有办法使用spring boot starter应用程序graphql spring boot starter公开2个graphql端点?_Graphql_Graphql Java - Fatal编程技术网

有没有办法使用spring boot starter应用程序graphql spring boot starter公开2个graphql端点?

有没有办法使用spring boot starter应用程序graphql spring boot starter公开2个graphql端点?,graphql,graphql-java,Graphql,Graphql Java,目前我们正在使用 <dependency> <groupId>com.graphql-java-kickstart</groupId> <artifactId>graphql-spring-boot-starter</artifactId> <version>${graphql-spring-starter.version}</version> &l

目前我们正在使用

    <dependency>
        <groupId>com.graphql-java-kickstart</groupId>
        <artifactId>graphql-spring-boot-starter</artifactId>
        <version>${graphql-spring-starter.version}</version>
    </dependency>

com.graphql-java-kickstart
graphql弹簧启动机
${graphql spring starter.version}

这样,我们就可以使用/graphql端点公开graphqlapi。我希望有这样的多个端点,/graphql1和/graphql2,以便根据端点定义不同的响应格式。最好的方法是什么?非常感谢您的任何输入。

它只是简单地创建一个
GraphQLHttpServlet
并配置其上下文路径。在封面下,它使用自动配置
GraphQLWebAutoConfiguration
GraphQLHttpServlet
定义为bean,并将上下文路径配置为
/graphql

这意味着您可以参考
GraphQLWebAutoConfiguration
的工作方式,并创建另一个注册到其他上下文路径的
GraphQLHttpServlet
实例

要点是,要在spring boot中注册一个
Servlet
,您只需创建一个
ServletRegistrationBean
,它包装您要创建的
HttpServlet
。有关更多详细信息,请参阅

一个简单的例子是:

@Bean
公共服务注册Bean fooGraphQLServlet(){
//创建并配置GraphQL模式。
GraphQLSchema=xxxxxxx;
GraphQLHttpServlet GraphQLHttpServlet=GraphQLHttpServlet.with(schema);
ServletRegistrationBean注册=新建ServletRegistrationBean(
graphQLHttpServlet,“/graphql2/*”;
registration.setName(“另一个GraphQL端点”);
申报登记;
} 

cors设置如何?