我有两个简单的类用于测试 Neo4j 服务器上的休息调用。 我已将 .jar 文件放置在插件目录中,其中包含路径,例如:
gov/lanl/graphing/execute/rest/HelloWorldResource.class
我修改了 neo4j-server.properties 文件,例如:
org.neo4j.server.thirdparty_jaxrs_class=
gov.lanl.graphing.execute.rest=/gov/lanl/graphing/execute/rest
我认为我对上述属性缺乏了解。
这里有两个类,HelloWorldResrource 类是插件目录中的类。注意:有一些奇怪的语法,所以请忽略奇怪的变量名称等。
这非常简单,我认为问题是我不明白 server.properties 文件中的路径应该如何在 Main 类中表示。谢谢你的帮助。
public class Resting {
public static String URI = "http://localhost:7474/gov/lanl/graphing/execute/rest/helloworld/";
public static void main (String[] args) {
Client client = Client.create();
client.addFilter(new LoggingFilter(System.out));
WebResource cypher = client.resource(URI + "rico");
ClientResponse cypherResponse = cypher.accept(MediaType.TEXT_PLAIN).get(ClientResponse.class);
cypherResponse.close();
System.out.println(cypherResponse);
}
}
@Path("/helloworld")
public class HelloWorldResource {
@GET
@Produces(MediaType.TEXT_PLAIN)
@Path("/{name}")
public Response hello(@PathParam("name") String name)
{
return Response.status(Status.OK).entity(
("hello there , " + name).getBytes(Charset.forName("UTF-8"))).build();
}
}
最佳答案
好吧,经过我的合资企业的多次争论。代码,我发现了几个错误。
首先:
org.neo4j.server.thirdparty_jaxrs_class=
应该:
org.neo4j.server.thirdparty_jaxrs_classes=
第二:
我没有正确配置 .jar 文件,我重新配置了此编译以正确包含类路径和降序目录。问题解决了。解决更困难的问题......
关于java - 需要简单的 Neo4j Rest 概念验证方面的帮助,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27628721/