我在Eclipse中使用maven依赖项并尝试使用bolt协议连接neo4j和java。我正在MacOS中运行应用程序。 我正在使用Eclipse 3和Java版本8和jre 1.8。这是我的pom.xml **
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.neo4j</groupId>
<artifactId>neo4j</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>neo4j</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.neo4j.driver</groupId>
<artifactId>neo4j-java-driver</artifactId>
<version>1.2.1</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.neo4j</groupId>
<artifactId>neo4j</artifactId>
<version>3.1.4</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
**
这是.java文件中调用的方法
void createDatabase()
{
GraphDatabaseService dfs = new GraphDatabaseFactory().newEmbeddedDatabase(dbPath);
System.out.println("Database created!!");
Config noSSL = Config.build().withEncryptionLevel(Config.EncryptionLevel.NONE).toConfig();
try(Driver dri = GraphDatabase.driver("bolt://localhost:7687", AuthTokens.basic( "neo4j", "hello" ), noSSL))
{
System.out.println("Database connected");
Session session = dri.session();
session.run("CREATE(a:Persona{name:{name}, title:{title}})", parameters("name","Aruna","title","Bhakt"));
System.out.println("\n\t1.CREATED");
StatementResult result =session.run("MATCH(a:Persona) WHERE a.name = {name}" +
"RETURN a.name AS name, a.title AS title",
parameters("name","Aruna"));
System.out.println("\n\t2.Match");
while(result.hasNext())
{
Record record = result.next();
System.out.println(record.get("title").asString() + " " + record.get("name").asString());
}
System.out.println("\n\t3.Found Record");
session.close();
dri.close();
}
}
运行应用程序后,我收到所有这些错误
Exception in thread "main" java.lang.RuntimeException: Error starting org.neo4j.kernel.impl.factory.GraphDatabaseFacadeFactory, /Users/arundhatiwahane/Documents/Neo4j/default.graphdb
at org.neo4j.kernel.impl.factory.GraphDatabaseFacadeFactory.initFacade(GraphDatabaseFacadeFactory.java:199)
at org.neo4j.kernel.impl.factory.GraphDatabaseFacadeFactory.newFacade(GraphDatabaseFacadeFactory.java:130)
at org.neo4j.graphdb.factory.GraphDatabaseFactory.newDatabase(GraphDatabaseFactory.java:101)
at org.neo4j.graphdb.factory.GraphDatabaseFactory.lambda$createDatabaseCreator$0(GraphDatabaseFactory.java:89)
at org.neo4j.graphdb.factory.GraphDatabaseFactory$$Lambda$1/1130478920.newDatabase(Unknown Source)
at org.neo4j.graphdb.factory.GraphDatabaseBuilder.newGraphDatabase(GraphDatabaseBuilder.java:183)
at org.neo4j.graphdb.factory.GraphDatabaseFactory.newEmbeddedDatabase(GraphDatabaseFactory.java:66)
at com.sampledb.createDatabase(sampledb.java:41)
at com.sampledb.main(sampledb.java:34)
Caused by: org.neo4j.kernel.lifecycle.LifecycleException: Component 'org.neo4j.kernel.internal.StoreLockerLifecycleAdapter@1b15e2a9' was successfully initialized, but failed to start. Please see attached cause exception.
at org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance.start(LifeSupport.java:443)
at org.neo4j.kernel.lifecycle.LifeSupport.start(LifeSupport.java:107)
at org.neo4j.kernel.impl.factory.GraphDatabaseFacadeFactory.initFacade(GraphDatabaseFacadeFactory.java:195)
... 8 more
Caused by: org.neo4j.kernel.StoreLockException: Store and its lock file has been locked by another process: /Users/arundhatiwahane/Documents/Neo4j/default.graphdb/store_lock. Please ensure no other process is using this database, and that the directory is writable (required even for read-only access)
at org.neo4j.kernel.internal.StoreLocker.storeLockException(StoreLocker.java:94)
at org.neo4j.kernel.internal.StoreLocker.checkLock(StoreLocker.java:80)
at org.neo4j.kernel.internal.StoreLockerLifecycleAdapter.start(StoreLockerLifecycleAdapter.java:40)
at org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance.start(LifeSupport.java:433)
... 10 more
请帮我弄清楚我的所有错误。
答案 0 :(得分:1)
另一个进程是锁定,杀死它
尝试
ps aux | grep neo4j
或
ps aux | grep java
阅读您的例外说明
Caused by: org.neo4j.kernel.StoreLockException: Store and its lock file has been locked by another process: /Users/arundhatiwahane/Documents/Neo4j/default.graphdb/store_lock. Please ensure no other process is using this database, and that the directory is writable (required even for read-only access)
如果查杀过程没有解决,则需要向目录
添加写权限chmod -R 777 /Users/arundhatiwahane/Documents/Neo4j/