Provide support to increase developer productivity in Java when using Neo4j. Uses familiar Spring concepts such as a template classes for core API usage and lightweight repository style data access.
APACHE-2.0 License
= Spring Data Neo4j image:https://jenkins.spring.io/buildStatus/icon?job=spring-data-neo4j%2Fmain&subject=Build[link=https://jenkins.spring.io/view/SpringData/job/spring-data-neo4j/] https://gitter.im/spring-projects/spring-data[image:https://badges.gitter.im/spring-projects/spring-data.svg[Gitter]] image:https://img.shields.io/badge/Revved%20up%20by-Develocity-06A0CE?logo=Gradle&labelColor=02303A["Revved up by Develocity", link="https://ge.spring.io/scans?search.rootProjectNames=Spring Data Neo4j"] :sectanchors:
// tag::properties[] :neo4jGroupId: org.springframework.data :artifactId: spring-data-neo4j :groupIdStarter: org.springframework.boot :artifactIdStarter: spring-boot-starter-data-neo4j
:docs-neo4j-version: 5.3.0 :docs-neo4j-docker-version: 5 :docs-neo4j-4-version: 4.4.16 :docs-neo4j-3-version: 3.5.23 :spring-boot-version: 3.0.1 :spring-data-neo4j-version: 7.0.1 // end::properties[]
The primary goal of the https://projects.spring.io/spring-data[Spring Data] project is to make it easier to build Spring-powered applications that use new data access technologies such as non-relational databases, map-reduce frameworks, and cloud based data services.
The SDN project aims to provide a familiar and consistent Spring-based programming model for integrating with the https://neo4j.com/[Neo4j] Graph Database.
== Code of Conduct
This project is governed by the link:https://github.com/spring-projects/.github/blob/main/CODE_OF_CONDUCT.md[Spring Code of Conduct]. By participating, you are expected to uphold this code of conduct. Please report unacceptable behavior to [email protected].
== Manual
For a gentle introduction and some getting started guides, please use our https://docs.spring.io/spring-data/neo4j/docs/current/reference/html/#reference[Manual].
== Getting Started
=== Maven configuration
==== With Spring Boot
If you are on https://spring.io/projects/spring-boot[Spring Boot], all you have to do is to add our starter:
and configure your database connection:
Please have a look at our https://docs.spring.io/spring-data/neo4j/docs/current/reference/html/#reference[manual] for an overview about the architecture, how to define mappings and more.
==== Without Spring Boot
If you are using a plain Spring Framework project without Spring Boot, please add this Maven dependency:
and configure SDN for reactive database access like this:
@Configuration @EnableReactiveNeo4jRepositories @EnableTransactionManagement class MyConfiguration extends AbstractReactiveNeo4jConfig {
@Bean
public Driver driver() {
return GraphDatabase.driver("bolt://localhost:7687", AuthTokens.basic("neo4j", "secret"));
}
@Override
protected Collection<String> getMappingBasePackages() {
return Collections.singletonList(Person.class.getPackage().getName());
}
The imperative version looks pretty much the same but uses EnableNeo4jRepositories
and AbstractNeo4jConfig
.
IMPORTANT: We recommend Spring Boot, the automatic configuration and especially the dependency management through the Starters in contrast to the manual work of managing dependencies and configuration.
Here is a quick teaser of a reactive application using Spring Data Repositories in Java:
@Node public class Person { private Long id; private String name;
public Person(String name) {
this.name = name;
}
}
@Repository interface PersonRepository extends ReactiveNeo4jRepository<Person, Long> {
Flux<Person> findAllByName(String name);
Flux<Person> findAllByNameLike(String name);
}
@Service class MyService {
@Autowired
private final PersonRepository repository;
@Transactional
public Flux<Person> doWork() {
Person emil = new Person("Emil");
Person gerrit = new Person("Gerrit");
Person michael = new Person("Michael");
// Persist entities and relationships to graph database
return repository.saveAll(Flux.just(emil, gerrit, michael));
}
=== Building SDN
Please have a look at the documentation: https://docs.spring.io/spring-data/neo4j/reference/#building-sdn-rx[Building SDN].
== Getting Help
Having trouble with Spring Data? We’d love to help!
new and noteworthy
" features.== Reporting Issues
Spring Data uses GitHub as issue tracking system to record bugs and feature requests. If you want to raise an issue, please follow the recommendations below:
== License
Spring Data Neo4j is Open Source software released under the https://www.apache.org/licenses/LICENSE-2.0.html[Apache 2.0 license].