For the latest stable version, please use Spring Data Neo4j 7.4.0!spring-doc.cn

Building Spring Data Neo4j

Requirements

About the JDK version

Choosing JDK 17 is a decision influenced by various aspectsspring-doc.cn

  • SDN is a Spring Data project. Spring Data commons baseline is JDK 17 and so is Spring Framework’s baseline. Thus, it is only natural to keep the JDK 17 baseline.spring-doc.cn

Running the build

The following sections are alternatives and roughly sorted by increased effort.spring-doc.cn

All builds require a local copy of the project:spring-doc.cn

Clone SDN
$ git clone [email protected]:spring-projects/spring-data-neo4j.git

Before you proceed, verify your locally installed JDK version. The output should be similar:spring-doc.cn

Verify your JDK
$ java -version
java version "18.0.1" 2022-04-19
Java(TM) SE Runtime Environment (build 18.0.1+10-24)
Java HotSpot(TM) 64-Bit Server VM (build 18.0.1+10-24, mixed mode, sharing)

With Docker installed

Using the default image

If you don’t have Docker installed, head over to Docker Desktop. In short, Docker is a tool that helps you running lightweight software images using OS-level virtualization in so-called containers.spring-doc.cn

Our build uses Testcontainers Neo4j to bring up a database instance.spring-doc.cn

Build with default settings on Linux / macOS
$ ./mvnw clean verify

On a Windows machine, usespring-doc.cn

Build with default settings on Windows
$ mvnw.cmd clean verify

The output should be similar.spring-doc.cn

Using another image

The image version to use can be configured through an environmental variable like this:spring-doc.cn

Build using a different Neo4j Docker image
$ SDN_NEO4J_VERSION=5.3.0-enterprise SDN_NEO4J_ACCEPT_COMMERCIAL_EDITION=yes ./mvnw clean verify

Here we are using 5.3.0 enterprise and also accept the license agreement.spring-doc.cn

Consult your operating system or shell manual on how to define environment variables if specifying them inline does not work for you.spring-doc.cn

Against a locally running database

Running against a locally running database will erase its complete content.

Building against a locally running database is faster, as it does not restart a container each time. We do this a lot during our development.spring-doc.cn

You can get a copy of Neo4j at our download center free of charge.spring-doc.cn

Please download the version applicable to your operating system and follow the instructions to start it. A required step is to open a browser and go to localhost:7474 after you started the database and change the default password from neo4j to something of your liking.spring-doc.cn

After that, you can run a complete build by specifying the local bolt URL:spring-doc.cn

Build using a locally running database
$ SDN_NEO4J_URL=bolt://localhost:7687 SDN_NEO4J_PASSWORD=verysecret ./mvnw clean verify

Summary of environment variables controlling the build

Name Default value Meaning

SDN_NEO4J_VERSIONspring-doc.cn

5.3.0spring-doc.cn

Version of the Neo4j docker image to use, see Neo4j Docker Official Imagesspring-doc.cn

SDN_NEO4J_ACCEPT_COMMERCIAL_EDITIONspring-doc.cn

nospring-doc.cn

Some tests may require the enterprise edition of Neo4j. We build and test against the enterprise edition internally, but we won’t force you to accept the license if you don’t want to.spring-doc.cn

SDN_NEO4J_URLspring-doc.cn

not setspring-doc.cn

Setting this environment allows connecting to a locally running Neo4j instance. We use this a lot during development.spring-doc.cn

SDN_NEO4J_PASSWORDspring-doc.cn

not setspring-doc.cn

Password for the neo4j user of the instance configured with SDN_NEO4J_URL.spring-doc.cn

You need to set both SDN_NEO4J_URL and SDN_NEO4J_PASSWORD to use a local instance.

Checkstyle and friends

There is no quality gate in place at the moment to ensure that the code/test ratio stays as is, but please consider adding tests to your contributions.spring-doc.cn

We have some rather mild checkstyle rules in place, enforcing more or less default Java formatting rules. Your build will break on formatting errors or something like unused imports.spring-doc.cn