我正在尝试将 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 类
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