I tried to dockerize my spring neo4j application.
It works locally when I use spring.neo4j.uri=bolt://localhost:7687
but, when I'm trying to put it in container and give it address bolt://registration_db:7687
(registration_db is name of container where neo4j is running) as environment variable i get exception:
Neo4jRepositoriesRegistrar.EnableNeo4jRepositoriesConfiguration: Cannot resolve reference to bean 'neo4jTemplate' while setting bean property 'neo4jOperations'
....
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'neo4jClient' defined in class path resource [org/springframework/boot/autoconfigure/data/neo4j/Neo4jDataAutoConfiguration.class]: Unsatisfied dependency expressed through method 'neo4jClient' parameter 0: Error creating bean with name 'neo4jDriver' defined in class path resource [org/springframework/boot/autoconfigure/neo4j/Neo4jAutoConfiguration.class]: Failed to instantiate [org.neo4j.driver.Driver]: Factory method 'neo4jDriver' threw exception with message: Invalid address format `bolt://registration_db:7687/neo4j`
pom:
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-neo4j</artifactId>
<version>7.1.0</version>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jpa</artifactId>
</dependency>
Currently i didn't change default spring boot neo4j configuration, should I try to configure it somehow or there is a other way to fix it?
It turned out, that '_' symbol is forbidden in address in spring neo4j, so easy fix was to change container name with database from registration_db to registration-db. So bolt://registration-db:7687 is valid as address (somehow).