SpringBoot集成Neo4j

Neo4j

# 集成原生Neo4J

<dependency>
    <groupId>org.neo4j.driver</groupId>
    <artifactId>neo4j-java-driver</artifactId>
    <version>4.4.12</version>
</dependency>
1
2
3
4
5

代码

public static void main(String[] args) {
    Driver driver = GraphDatabase.driver("bolt://localhost:7687", AuthTokens.basic("neo4j", "Yinlidong1995."));
    Session session = driver.session();
    session.run("CREATE (n:Part {name: {name},title: {title}})",
                parameters("name", "Arthur001", "title", "King001"));
    Result result = session.run("MATCH (a:Part) WHERE a.name = {name} " +
                                "RETURN a.name AS name, a.title AS title",
                                parameters("name", "Arthur001"));
    while (result.hasNext()) {
        Record record = result.next();
        System.out.println(record.get("title").asString() + " " + record.get("name").asString());
    }
    session.close();
    driver.close();
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15

# SpringBoot集成Neo4J

# 参考资料

https://zhuanlan.zhihu.com/p/450327256

最近修改于: 2023/11/26 22:43:49
和宇宙温柔的关联
房东的猫