= Spring Data Neo4j⚡️RX :sectanchors:
// tag::properties[] :groupId: org.neo4j.springframework.data :artifactId: spring-data-neo4j-rx :artifactIdStarter: spring-data-neo4j-rx-spring-boot-starter
:neo4j-version: 4.0.4 :spring-boot-version: 2.3.0.RELEASE :spring-data-neo4j-rx-version: 1.1.1 // end::properties[]
image:https://img.shields.io/maven-central/v/org.neo4j.springframework.data/spring-data-neo4j-rx.svg[Maven Central,link=http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22org.neo4j.springframework.data%22%20AND%20a%3A%22spring-data-neo4j-rx%22]
IMPORTANT: This repository of SDN/RX was set to read-only mode. We migrated the project as the successor of the original Spring Data Neo4j to https://github.com/spring-projects/spring-data-neo4j. We have moved the issues to the https://jira.spring.io/projects/DATAGRAPH[Spring Jira] where we also will track the new ones.
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/RX project aims to provide a familiar and consistent Spring-based programming model for integrating with the https://neo4j.com/[Neo4j] Graph Database.
== Manual
For a gentle introduction and some getting started guides, please use our https://neo4j.github.io/sdn-rx[Manual].
== Getting Started
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));
}
TIP: SDN/RX is not only about reactive support, all features are available in both ways: Imperative and reactive, we only prefer to showcase the new reactive database access support here.
=== 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://neo4j.github.io/sdn-rx[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/RX 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. + Please consult our https://neo4j.github.io/sdn-rx[manual] for more information.
=== Building SDN/RX
Please have a look at the documentation: https://neo4j.github.io/sdn-rx/current/#building-sdn-rx[Building SDN/RX].