如何在Java Application中使用Neo4j的cyper查询

时间:2012-11-01 07:09:53

标签: java neo4j

我正在使用CypersQueries从java Applicaton创建节点。我正在关注上述链接

http://docs.neo4j.org/chunked/milestone/query-create.html

在我的javaApplication中,我使用了上面的示例查询

public class CretaeQuery
{
    public static final String DBPATH="D:/Neo4j/CQL";

    public static void main(String args[])
    {
        GraphDatabaseService path=new EmbeddedGraphDatabase(DBPATH);
        Transaction tx=path.beginTx();
        try
        {
        Map<String, Object> props  = new HashMap<String, Object>();
        props .put( "name", "Sharon" );
        props .put( "position", "Engineer" );

        Map<String, Object> params = new HashMap<String, Object>();
        params.put( "props", props  );

        ExecutionEngine engine=new ExecutionEngine(path);
        ExecutionResult result=engine.execute( "create ({props})", params );
        System.out.println(result);
        tx.success();
        } 
        finally
        {
             tx.finish();
             path.shutdown();

        }
    }
}

当我运行上述课程时,我正面对上述错误

Exception in thread "main" java.lang.NoClassDefFoundError: com/googlecode/concurrentlinkedhashmap/ConcurrentLinkedHashMap$Builder
    at org.neo4j.cypher.internal.LRUCache.<init>(LRUCache.scala:30)
    at org.neo4j.cypher.ExecutionEngine$$anon$1.<init>(ExecutionEngine.scala:84)
    at org.neo4j.cypher.ExecutionEngine.<init>(ExecutionEngine.scala:84)
    at com.neo4j.CretaeQuery.main(CretaeQuery.java:33)
Caused by: java.lang.ClassNotFoundException: com.googlecode.concurrentlinkedhashmap.ConcurrentLinkedHashMap$Builder
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    ... 4 more

我不知道为什么错误会抛出。请用正确的代码建议我

1 个答案:

答案 0 :(得分:1)

您丢失了类路径中的内容,或者服务器未正确初始化。 concurrenthashmap大约在一个月前放入,作为/ lib中的jar。这是嵌入模式还是服务器模式?