For the latest stable version, please use Spring Data Neo4j 7.3.4! |
Building Spring Data Neo4j
Requirements
-
JDK 17+ (Can be OpenJDK or Oracle JDK)
-
Maven 3.8.5 (We provide the Maven wrapper, see
mvnw
respectivelymvnw.cmd
in the project root; the wrapper downloads the appropriate Maven version automatically) -
A Neo4j 5.+ database, either
-
running locally
-
or indirectly via Testcontainers and Docker
-
Running the build
The following sections are alternatives and roughly sorted by increased effort.
All builds require a local copy of the project:
$ git clone [email protected]:spring-projects/spring-data-neo4j.git
Before you proceed, verify your locally installed JDK version. The output should be similar:
$ 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.
Our build uses Testcontainers Neo4j to bring up a database instance.
$ ./mvnw clean verify
On a Windows machine, use
$ mvnw.cmd clean verify
The output should be similar.
Using another image
The image version to use can be configured through an environmental variable like this:
$ 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.
Consult your operating system or shell manual on how to define environment variables if specifying them inline does not work for you.
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.
You can get a copy of Neo4j at our download center free of charge.
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.
After that, you can run a complete build by specifying the local bolt
URL:
$ SDN_NEO4J_URL=bolt://localhost:7687 SDN_NEO4J_PASSWORD=verysecret ./mvnw clean verify
Summary of environment variables controlling the build
Name | Default value | Meaning |
---|---|---|
|
5.3.0 |
Version of the Neo4j docker image to use, see Neo4j Docker Official Images |
|
no |
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. |
|
not set |
Setting this environment allows connecting to a locally running Neo4j instance. We use this a lot during development. |
|
not set |
Password for the |
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.
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.