使用原生的这种方式 导入 坐标
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-neo4j</artifactId> <version>2.5.8</version> </dependency> <dependency> <groupId>org.neo4j</groupId> <artifactId>neo4j-ogm-http-driver</artifactId> <version>3.2.1</version> </dependency>
<!--父类依赖--> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.5.8</version> <relativePath/> <!-- lookup parent from repository --> </parent>
编写测试类
package com.po.neo4j.test; import org.neo4j.driver.*; import static org.neo4j.driver.Values.parameters; public class TestNeo4j { public static void main(String[] args) { Driver driver = GraphDatabase.driver("bolt://localhost:7687", AuthTokens.basic("popo", "123456")); 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(); } }
执行
标签:原生,java,name,title,org,driver,session,neo4j,neo4J From: https://www.cnblogs.com/popopopopo/p/16814033.html