- neo4j 官网文档
- spring-boot-starter-data-neo4j
- spring-data-neo4j
- 使用 Neo4j 访问数据
- Neo4j Spring动态起始节点类型实现 示例
- springboot 连接neo4j认证报错解决方案
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-neo4j</artifactId>
</dependency>
@Data
@NodeEntity
public class Person implements Serializable {
@Id
@GeneratedValue
private Long id;
private String name;
}
public interface PersonRepository extends Neo4jRepository<Person, Long> {
List<Person> findByName(String name);
}
测试类
@SpringBootTest
public class PersonRepositoryTests {
@Resource
private PersonRepository personRepository;
@Test
void save() {
Person person = new Person();
person.setId(1L);
person.setName("lisi");
personRepository.save(person);
}
@Test
void findAll() {
List<Person> all = (List<Person>)personRepository.findAll();
System.out.println(all);
}
}