Skip to content

Latest commit

 

History

History

springboot-db-neo4j

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

springboot-db-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);
    }
}