如何解决 java.lang.NoSuchMethodError: org.neo4j.helpers.collection.Iterables.toList(Ljava/lang/Iterable;)Ljava/util/List? [英] How can I resolve java.lang.NoSuchMethodError: org.neo4j.helpers.collection.Iterables.toList(Ljava/lang/Iterable;)Ljava/util/List?

查看:70
本文介绍了如何解决 java.lang.NoSuchMethodError: org.neo4j.helpers.collection.Iterables.toList(Ljava/lang/Iterable;)Ljava/util/List?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 Java 中的嵌入式 neo4j 在 neo4j 中插入节点,但出现此错误,我使用的是 neo4j 3.1.1 和 netbeans 7

I'm trying insert nodes in neo4j using embedded neo4j in java, but I obtain this error, i'm using neo4j 3.1.1 and netbeans 7

Exception in thread "main" java.lang.NoSuchMethodError: org.neo4j.helpers.collection.Iterables.toList(Ljava/lang/Iterable;)Ljava/util/List;
    at org.neo4j.graphdb.factory.GraphDatabaseFactory.<init>(GraphDatabaseFactory.java:49)
    at twitter4j.EmbeddeNeo4j.createDb(EmbeddeNeo4j.java:41)

不知道是不是变量DB_PATH = "D:\\Neo4j CE 3.1.1\\graph database"变量 DB_PATH 应该包含什么?代码是:

I don't know if the problem in variable DB_PATH = "D:\\Neo4j CE 3.1.1\\graph database" what should the variable DB_PATH be contained? the code is :

void createDb() {
        clearDb();
        // start DB
        graphDb = new GraphDatabaseFactory().newEmbeddedDatabase(DB_PATH);
        registerShutdownHook(graphDb);

        // start Transaction
        Transaction tx = graphDb.beginTx();
        try {
            // adding data
            firstNode = graphDb.createNode();
            firstNode.setProperty("message", "Hello, ");
            secondNode = graphDb.createNode();
            secondNode.setProperty("message", "World!");

            relationship = firstNode.createRelationshipTo(secondNode, RelTypes.KNOWS);
            relationship.setProperty("message", "brave Neo4j ");

            // reading data
            System.out.println(firstNode.getProperty("message"));
            System.out.println(relationship.getProperty("message"));
            System.out.println(secondNode.getProperty("message"));

            greeting = (String) firstNode.getProperty("message") + (String) relationship.getProperty("message") + (String) secondNode.getProperty("message");

            Iterator<Relationship> it = firstNode.getRelationships().iterator();
            while(it.hasNext()) {
                Relationship r = it.next();
                Node[] nodes = r.getNodes();
                System.out.println(nodes[0].getProperty("message") + " " + r.getProperty("message") + " " + nodes[1].getProperty("message"));
            }

            tx.success();
        } finally {
            tx.terminate();
        }

    }

private void clearDb() {
    try {
        FileUtils.deleteRecursively(new File(DB_PATH));
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}

推荐答案

我基本上遇到了同样的问题;这是由于 CLASSPATH 中存在旧版本的 Neo4J 以及我尝试使用的新版本造成的.(我在此过程中了解到,我的 IDE 在构建新目标之前不会清除旧目标,这就是旧版本存在的原因.)

I had essentially this same problem; it was caused by the presence of older versions of Neo4J in the CLASSPATH along with the new one I was trying to use. (I learned along the way that my IDE doesn't clean out old targets before building new ones, which is why the older versions were there.)

确保您已清除所有旧版本的相关 .jar.

Make sure that you've flushed out all older versions of the relevant .jars.

这篇关于如何解决 java.lang.NoSuchMethodError: org.neo4j.helpers.collection.Iterables.toList(Ljava/lang/Iterable;)Ljava/util/List?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆