为什么在java中的这个示例代码不工作?

问题描述:

在这个页面中的Java部分:https://neo4j.com/blog/cypher-load-json-from-url/为什么在java中的这个示例代码不工作?

线

db.execute(query, singletonMap("json",json)); 

给出了一个错误,那就是The method execute(String, Map<String,Map>) is undefined for the type GraphDatabaseService

在类GraphDatabaseService中没有名为“execute”的方法,我无法找到有关此类的文档。有谁知道发生了什么?

neo4j是否改变了它的库,并没有相应地调整代码,或者我错过了一些需要下载的库(我已经下载了neo4j-kernel-1.8.1.jar和neo4j-java-driver-1.1.0.sources .jar并将它们添加到路径中)?

使用Neo4j 2.2.0或更高版本。

execute方法已被添加到版本为2.2.0的GraphDatabaseService

比较:Neo4J 2.2.0Neo4J 2.1.8

还要注意的是GraphDatabaseService在较新的版本搬到neo4j-graphdb-api-x.y.z.jar,而你会发现它在neo4j-kernel-x.y.z.jar为更低的版本。