如何将spring docker容器连接到neo4j

问题描述 投票:0回答:1

我尝试对我的 Spring Neo4j 应用程序进行 dockerize。

当我使用

spring.neo4j.uri=bolt://localhost:7687
时,它可以在本地工作,但是,当我尝试将其放入容器中并为其提供地址
bolt://registration_db:7687
(registration_db是运行neo4j的容器的名称)作为环境变量时,我得到异常:

Neo4jRepositoriesRegistrar.EnableNeo4jRepositoriesConfiguration:在设置 bean 属性“neo4jOperations”时无法解析对 bean“neo4jTemplate”的引用

....

引起:org.springframework.beans.factory.UnsatisfiedDependencyException:创建在类路径资源[org/springframework/boot/autoconfigure/data/neo4j/Neo4jDataAutoConfiguration.class]中定义的名为“neo4jClient”的bean时出错:通过方法表达的依赖关系不满足'neo4jClient'参数0:创建在类路径资源[org/springframework/boot/autoconfigure/neo4j/Neo4jAutoConfiguration.class]中定义的名称为'neo4jDriver'的bean时出错:无法实例化[org.neo4j.driver.Driver]:工厂方法“neo4jDriver”抛出异常并显示消息:地址格式无效`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>

目前我没有更改默认的 spring boot neo4j 配置,我应该尝试以某种方式配置它还是有其他方法来修复它?

spring-boot neo4j spring-data-jpa spring-data-neo4j
1个回答
0
投票

事实证明,Spring Neo4j 中的地址中禁止使用“_”符号,因此简单的解决方法是将数据库的容器名称从registration_db 更改为registration-db。因此,bolt://registration-db:7687 作为地址是有效的(以某种方式)。

© www.soinside.com 2019 - 2024. All rights reserved.