Liquigraph provides a Spring Boot starter.
It is a good fit if your Spring Boot application owns (well-identified parts of) the data in Neo4j.
Make sure a JDK is set up on the machine running the CLI.
For Neo4j 3.x, the minimal JDK version is 8.
For Neo4j 4.x, the minimal JDK version is 11.
For this particular example, a simple Spring Boot application with a Maven build is assumed.
Liquigraph requires a single entry point, also known as a change log file. This file can include other change log files and/or define change sets.
Every change set is executed in a separate transaction. They define at least 1 Cypher query. These Cypher queries define the data (or indices/constraints) that will be created, modified or deleted from the target database.
Neo4j disallows mixing index/constraint with regular "data" operations within the same transaction. Such a transaction will always fail. As a consequence, index/constraint operations must be defined in separate Liquigraph change sets.
Change sets are uniquely identified by their ID and author name. By default, they also are:
- incremental: they are allowed to run only once.
- immutable: their queries are not allowed to change.
Learn how to change these defaults, and more, in the reference documentation.
Change log creation⚓
Save the following change log file:
1 2 3 4 5 6 7 8 9 10
The change log defines two change sets, which are executed in order, in separate transactions:
- The first change set defines a single query, which creates a node, with a
Sentencelabel and a simple textual property called
- The second change set defines a single Cypher query as well, which finds the node pattern and updates the
If the Cypher syntax looks unfamiliar, feel free to follow this official tutorial.
The location of this file will be called
CHANGELOG_FILE throughout the rest of the tutorial.
Contrary to Liquibase, Liquigraph only supports XML for defining change logs.
The connection URI will be
neo4j and the password
Depending on Neo4j versions, Neo4j server typology and Liquigraph client, connection URI can vary greatly. The configuration is covered in much greater details in the reference documentation.
Add the following dependencies to your POM file:
<dependency> <groupId>org.liquigraph</groupId> <artifactId>liquigraph-spring-boot-starter</artifactId> <version>4.0.4</version> </dependency> <dependency> <groupId>org.neo4j</groupId> <!-- change this to neo4j-jdbc-http for HTTP connections to Neo4j --> <artifactId>neo4j-jdbc-bolt</artifactId> <version>4.0.4</version> <scope>runtime</scope> </dependency>
<dependency> <groupId>org.liquigraph</groupId> <artifactId>liquigraph-spring-boot-starter</artifactId> <version>3.1.2</version> </dependency> <dependency> <groupId>org.neo4j</groupId> <!-- change this to neo4j-jdbc-http for HTTP connections to Neo4j --> <artifactId>neo4j-jdbc-bolt</artifactId> <version>3.5.2</version> <scope>runtime</scope> </dependency>
You also need to configure your application with the Neo4j connection settings required by Liquigraph (in
src/main/resources/application.properties for instance):
spring.datasource.url=jdbc:neo4j:bolt://localhost spring.datasource.driver-class-name=org.neo4j.jdbc.bolt.BoltDriver spring.datasource.username=neo4j spring.datasource.password=changeme
CHANGELOG_FILE should be stored in
src/main/resources/db/liquigraph/changelog.xml for the example to work.
You just need to run:
You can then check the data has been added in Neo4j Browser with the following Cypher query:
MATCH (sentence:Sentence) RETURN sentence.text AS text
The result should be "Hello world!".
You can re-run the same Liquigraph command several times and observe that the graph remains unchanged. In other words, the following Cypher query:
MATCH (sentence:Sentence) RETURN COUNT(sentence)
... should indeed always return 1.
Good to know
If you ever run a less specific Cypher query such as
MATCH (n) RETURN n, you will see that more node and relationships
This is normal: Liquigraph persists the change log history in the same database.
The change log history graph structure is covered in much more details in the reference documentation.