[RuntimeException:java.lang.ClassNotFoundException:]:Neo4J OGM使用Play框架Java 2.4.2

时间:2015-08-24 14:29:54

标签: java neo4j playframework-2.1 neo4j-ogm

我正在尝试将Neo4J OGM 1.1.1与Play 2 Java框架2.4.2一起使用。但是,当我运行应用程序时,我看到ClassNotFoundException。 以下是我的会议工厂类:

package org.neo;

import org.neo4j.ogm.session.Session;
import org.neo4j.ogm.session.SessionFactory;

public class Neo4jSessionFactory {


    private static SessionFactory sessionFactory = new SessionFactory("org.neo.models");
    private static Neo4jSessionFactory factory = new Neo4jSessionFactory();

    public static Neo4jSessionFactory getInstance() {
        return factory;
    }

    private Neo4jSessionFactory() {

        System.setProperty("username", "neo4j");
        System.setProperty("password", "neo");
    }

    public Session getNeo4jSession() {
        return sessionFactory.openSession("http://localhost:7474");
    }
}

org.neo.models.School class

package org.neo.models;

import org.neo4j.ogm.annotation.NodeEntity;
import org.neo4j.ogm.annotation.Relationship;

import java.util.HashSet;
import java.util.Set;

@NodeEntity(label = "School")
public class School extends Entity {

    String name;

    @Relationship(type = "DEPARTMENT")
    Set<Department> departments;

    @Relationship(type = "STAFF")
    Set<Teacher> teachers;

    @Relationship(type = "HEAD_TEACHER")
    Teacher headTeacher;

    @Relationship(type = "STUDENT")
    Set<Student> students;

    public School() {
        this.departments = new HashSet<>();
        this.teachers = new HashSet<>();
        this.students = new HashSet<>();
    }

    public School(String name) {
        this();
        this.name = name;
    }

    @Override
    public String toString() {
        return "School{" +
                "id=" + getId() +
                ", name='" + name + '\'' +
                ", departments=" + departments.size() +
                ", teachers=" + teachers.size() +
                ", students=" + students.size() +
                '}';
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Set<Department> getDepartments() {
        return departments;
    }

    public void setDepartments(Set<Department> departments) {
        this.departments = departments;
    }

    public Set<Teacher> getTeachers() {
        return teachers;
    }

    public void setTeachers(Set<Teacher> teachers) {
        this.teachers = teachers;
    }

    public Teacher getHeadTeacher() {
        return headTeacher;
    }

    public void setHeadTeacher(Teacher headTeacher) {
        this.headTeacher = headTeacher;
    }

    public Set<Student> getStudents() {
        return students;
    }

    public void setStudents(Set<Student> students) {
        this.students = students;
    }
}

可以在https://github.com/neo4j/neo4j-ogm/issues/34

找到异常详细信息

1 个答案:

答案 0 :(得分:0)

问题已经解决,需要在neo4j-ogm中进行额外的工作。

请参阅:https://github.com/neo4j/neo4j-ogm/issues/34