0

我是 Neo4j 图形数据库的新手,我想从 java Application 创建 CyperQueries 。我正在使用上面的 neo4j 手册

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

我正在从 java 应用程序创建节点,如下所示

public class CreateQuery
{
    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( "Firstnamename", "Sharon" );
        props .put( "lastname", "Eunis" );

        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();

        }
    }
}

我收到上述错误。我不知道这个错误,请任何 1 帮助尽快解决。

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.CreateQuery.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
4

3 回答 3

1

您可能需要添加此库的最新版本(Java 的 ConcurrentLinkedHashMap):

http://concurrentlinkedhashmap.googlecode.com/files/concurrentlinkedhashmap-lru-1.3.1.jar

于 2012-12-31T07:13:23.450 回答
0

您共享的代码工作正常。我认为问题在于您的导入语句。它们应该是这样的:

import java.util.HashMap;
import java.util.Map;
import org.neo4j.cypher.javacompat.ExecutionEngine;
import org.neo4j.cypher.javacompat.ExecutionResult;
import org.neo4j.graphdb.GraphDatabaseService;
import org.neo4j.graphdb.Transaction;
import org.neo4j.kernel.EmbeddedGraphDatabase;
于 2012-11-02T10:33:42.967 回答
0

它看起来像一个库错误。也许您导入了错误的版本?

以防万一,我应该指出您打算使用 GDB 工厂来构建嵌入式实例:

graphDb = new GraphDatabaseFactory().newEmbeddedDatabase(DB_PATH);

不确定它会有所作为。

于 2014-03-28T10:49:04.527 回答