12.2.4 Configuring Neo4j

Micronaut features dedicated support for automatically configuring the Neo4j Bolt Driver for the popular Neo4j Graph Database.

Using the CLI

If you are creating your project using the Micronaut CLI, supply the neo4j-bolt feature to configure the Neo4j Bolt driver in your project:

  1. $ mn create-app my-app features neo4j-bolt

To configure the Neo4j Bolt driver you should first add the neo4j-bolt module to your classpath:

  1. implementation("io.micronaut:micronaut-neo4j-bolt")
  1. <dependency>
  2. <groupId>io.micronaut</groupId>
  3. <artifactId>micronaut-neo4j-bolt</artifactId>
  4. </dependency>

You should then configure the URI of the Neo4j server you wish to communicate with in application.yml:

Configuring neo4j.uri

  1. neo4j:
  2. uri: bolt://localhost
The neo4j.uri setting should be in the format as described in the Connection URIs section of the Neo4j documentation

Once you have the above configuration in place you can inject an instance of the org.neo4j.driver.v1.Driver bean, which features both a synchronous blocking API and a non-blocking API based on CompletableFuture.

See the Micronaut Neo4j documentation for further information on configuring and using Neo4j within Micronaut.