Java Neo4j手册中的Jersey客户端示例

Java Neo4j手册中的Jersey客户端示例,java,neo4j,jersey-client,Java,Neo4j,Jersey Client,我想使用Jersey客户端通过REST与Neo4j数据库连接。在Neo4j手册中,他们在教程->语言->如何从Java使用RESTAPI中提供了这方面的示例。我想创建一个新节点,然后使用Cypher向其添加关系。在Neo4j示例()中,它们使用“createNode”,但文档表明,这仅在使用嵌入式Neo4j服务器时可用 调用createNode()在RESTful上下文中有效吗?在您引用的示例中,定义的createNode函数只是向http://localhost:7474/db/data/no

我想使用Jersey客户端通过REST与Neo4j数据库连接。在Neo4j手册中,他们在教程->语言->如何从Java使用RESTAPI中提供了这方面的示例。我想创建一个新节点,然后使用Cypher向其添加关系。在Neo4j示例()中,它们使用“createNode”,但文档表明,这仅在使用嵌入式Neo4j服务器时可用


调用createNode()在RESTful上下文中有效吗?

在您引用的示例中,定义的
createNode
函数只是向
http://localhost:7474/db/data/node
这将创建一个新节点:

private static URI createNode()
{
    final String nodeEntryPointUri = SERVER_ROOT_URI + "node";
    // http://localhost:7474/db/data/node

    WebResource resource = Client.create()
            .resource( nodeEntryPointUri );
    // POST {} to the node entry point URI
    ClientResponse response = resource.accept( MediaType.APPLICATION_JSON )
            .type( MediaType.APPLICATION_JSON )
            .entity( "{}" )
            .post( ClientResponse.class );

    final URI location = response.getLocation();
    System.out.println( String.format(
            "POST to [%s], status code [%d], location header [%s]",
            nodeEntryPointUri, response.getStatus(), location.toString() ) );
    response.close();

    return location;
}
此函数在示例代码中定义,与示例代码完全不同


如果您有兴趣使用新的Neo4j 3.0版本(当前为RC),则有一个新的支持Cypher的Java驱动程序。

在您参考的示例中,定义的
createNode
函数只是向
发出HTTP POST请求http://localhost:7474/db/data/node
这将创建一个新节点:

private static URI createNode()
{
    final String nodeEntryPointUri = SERVER_ROOT_URI + "node";
    // http://localhost:7474/db/data/node

    WebResource resource = Client.create()
            .resource( nodeEntryPointUri );
    // POST {} to the node entry point URI
    ClientResponse response = resource.accept( MediaType.APPLICATION_JSON )
            .type( MediaType.APPLICATION_JSON )
            .entity( "{}" )
            .post( ClientResponse.class );

    final URI location = response.getLocation();
    System.out.println( String.format(
            "POST to [%s], status code [%d], location header [%s]",
            nodeEntryPointUri, response.getStatus(), location.toString() ) );
    response.close();

    return location;
}
此函数在示例代码中定义,与示例代码完全不同


如果您对使用新的Neo4j 3.0版本(目前为RC)感兴趣,那么有一个新的支持Cypher的Java驱动程序。

如果这个问题太不清楚或太愚蠢,我道歉。但我真的不知道答案。至少有人能给我指一下手册中我能找到答案的部分吗?谢谢你如果这个问题太愚蠢或太愚蠢,我道歉。但我真的不知道答案。至少有人能给我指一下手册中我能找到答案的部分吗?谢谢你,威廉。谢谢你的澄清,谢谢你,威廉。谢谢你的澄清。