使用Maven编译Neo4J项目时找不到GraphDatabaseFactory



我正在尝试编译一个简单的项目,该项目使用graphdatabaseFactAse创建数据库,并使用此命令:

mvn compile

然后,我将获得成功,但是当试图执行此文件时:

`
package com.milanamos;
import java.io.File;
import java.io.IOException;
import org.neo4j.graphdb.GraphDatabaseService;
import org.neo4j.graphdb.factory.GraphDatabaseFactory;

public class MilanamosCmd {

    public static void main(String[] args) throws IOException {
        final int n = 10;
        GraphDatabaseFactory dbFactory = new GraphDatabaseFactory();
        GraphDatabaseService db= dbFactory.newEmbeddedDatabase(new File("C:/Documents"));
            long t2 = System.currentTimeMillis();
            ............
            long t3 = System.currentTimeMillis();
            System.out.println("GENERATE "+ (t3-t2) +"ms");
            System.out.println("Done successfully");
    } 
}`

我得到了:

`
[INFO] --- exec-maven-plugin:1.6.0:java (default-cli) @ planetoptim-neo4j ---
[WARNING]
java.lang.NoClassDefFoundError: org/neo4j/graphdb/factory/GraphDatabaseFactory
        at com.milanamos.MilanamosCmd.main(MilanamosCmd.java:24)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.codehaus.mojo.exec.ExecJavaMojo$1.run(ExecJavaMojo.java:282)
        at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.ClassNotFoundException: org.neo4j.graphdb.factory.GraphDatabaseFactory
        at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
        ... 7 more
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.919 s
[INFO] Finished at: 2017-09-10T19:56:10+02:00
[INFO] Final Memory: 19M/609M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.6.0:java (default-cli) on project planetoptim-neo4j: An exception occured while executing the Java class. org/neo4j/graphdb/factory/GraphDatabaseFactory: org.neo4j.graphdb.factory.GraphDatabaseFactory -> `

请提供任何帮助。

谢谢

Maven存储库中的新NEO4J版本可能不存在您上面提到的软件包结构中。我面临着版本的同样错误

<dependency>
    <groupId>org.neo4j</groupId>
    <artifactId>neo4j-kernel</artifactId>
    <version>4.1.3</version>
</dependency>

我将版本更改为

时解决了错误
<dependency>
    <groupId>org.neo4j</groupId>
    <artifactId>neo4j-kernel</artifactId>
    <version>3.4.18</version>
</dependency>

相关内容

  • 没有找到相关文章

最新更新