我有这样的代码:
import org.neo4j.graphdb.GraphDatabaseService;
import org.neo4j.graphdb.Node;
import org.neo4j.graphdb.Relationship;
import org.neo4j.graphdb.RelationshipType;
import org.neo4j.graphdb.Transaction;
import org.neo4j.graphdb.factory.GraphDatabaseFactory;
import org.neo4j.graphdb.index.Index;
public class Model
{
private static GraphDatabaseService GraphDb_;
private static Boolean Init_ = false;
private static Index<Node> NodeIndex_;
private static enum RelTypes implements RelationshipType
{
Parent, Child
}
public Model()
{
}
public static void init(String path)
{
if ( Init_ == false )
GraphDb_ = new GraphDatabaseFactory().newEmbeddedDatabase( path );
NodeIndex_ = GraphDb_.index().forNodes( "nodes" );
Init_ = true;
}
在尝试调用 Model.init("./database/") 后,我得到了字符串“GraphDb_ = new GraphDatabaseFactory().newEmbeddedDatabase(path)”:
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at java.util.concurrent.ConcurrentHashMap.put(ConcurrentHashMap.java:1124)
at java.util.concurrent.ConcurrentHashMap.putAll(ConcurrentHashMap.java:1162)
at org.neo4j.kernel.configuration.Config.applyChanges(Config.java:130)
at org.neo4j.kernel.configuration.Config.<init>(Config.java:91)
at org.neo4j.kernel.InternalAbstractGraphDatabase.<init>(InternalAbstractGraphDatabase.java:218)
at org.neo4j.kernel.EmbeddedGraphDatabase.<init>(EmbeddedGraphDatabase.java:103)
at org.neo4j.graphdb.factory.GraphDatabaseFactory$1.newDatabase(GraphDatabaseFactory.java:88)
at org.neo4j.graphdb.factory.GraphDatabaseBuilder.newGraphDatabase(GraphDatabaseBuilder.java:207)
at org.neo4j.graphdb.factory.GraphDatabaseFactory.newEmbeddedDatabase(GraphDatabaseFactory.java:69)
at neosample.Model.init(Model.java:55)
这出现在应用程序启动之前。Neo4J 1.9.2,Java 1.7.0