|
|
|
@ -2,7 +2,6 @@ package com.dsideal.Res.Plugin;
|
|
|
|
|
|
|
|
|
|
import lombok.Getter;
|
|
|
|
|
import org.neo4j.driver.*;
|
|
|
|
|
import org.neo4j.driver.async.AsyncSession;
|
|
|
|
|
import org.neo4j.driver.Config;
|
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
@ -50,23 +49,6 @@ public class Neo4jPlugin {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Session getSession() {
|
|
|
|
|
if (driver == null) {
|
|
|
|
|
throw new IllegalStateException("Neo4j驱动未初始化");
|
|
|
|
|
}
|
|
|
|
|
return driver.session(SessionConfig.builder()
|
|
|
|
|
.withDefaultAccessMode(AccessMode.WRITE) // 默认访问模式
|
|
|
|
|
.withDatabase("neo4j") // 指定数据库名称
|
|
|
|
|
.build());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public AsyncSession getAsyncSession() {
|
|
|
|
|
if (driver == null) {
|
|
|
|
|
throw new IllegalStateException("Neo4j驱动未初始化");
|
|
|
|
|
}
|
|
|
|
|
return driver.session(AsyncSession.class);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void close() {
|
|
|
|
|
if (driver != null) {
|
|
|
|
|
driver.close();
|
|
|
|
|