版本依赖关系
目前需要jdk17
maven依赖
<dependency>
<groupId>org.neo4j.driver</groupId>
<artifactId>neo4j-java-driver</artifactId>
<version>5.1.0</version>
</dependency>
生成驱动实例示例
// Import all relevant classes from neo4j-java-driver dependency
import org.neo4j.driver.*;
static String username = "neo4j";
static String password = "letmein!";
// Create a new Driver instance
static Driver driver = GraphDatabase.driver("neo4j://localhost:7687",
AuthTokens.basic(username, password));
生成驱动实例
var driver = GraphDatabase.driver(
connectionString, // (1)
authenticationToken, // (2)
configuration // (3)
)
1.connection String
2.authentication Token
AuthToken authenticationToken = AuthTokens.basic(username, password);
3.additional driver Configuration
Config config = Config.builder()
.withConnectionTimeout(30, TimeUnit.SECONDS)
.withMaxConnectionLifetime(30, TimeUnit.MINUTES)
.withMaxConnectionPoolSize(10)
.withConnectionAcquisitionTimeout(20, TimeUnit.SECONDS)
.withFetchSize(1000)
.withDriverMetrics()
.withLogging(Logging.console(Level.INFO))
.build();
验证连接是否正常
// Verify the connection details
driver.verifyConnectivity();
6325

被折叠的 条评论
为什么被折叠?



