簡體   English   中英

無法從 spring-boot-starter-data-neo4j 連接到雲托管的 Neo4j 服務器

[英]Cannot connect from spring-boot-starter-data-neo4j to cloud hosted neo4j server

我正在為一個項目使用 neo4j,並且我有一個 Neo4j 的谷歌雲實例正在運行。 使用bolt協議,我可以通過neo4j瀏覽器連接到這個實例。 在該項目中,它可以在我的筆記本電腦上運行本地連接,但是當我使用與瀏覽器中用於雲實例相同的螺栓連接 uri 時,我收到此錯誤:

org.neo4j.driver.exceptions.ServiceUnavailableException: Connection to the database terminated. Please ensure that your database is listening on the correct host and port and that you have compatible encryption settings both on Neo4j server and driver. Note that the default encryption setting has changed in Neo4j 4.0.

顯然,它與加密設置有關。 但是,經過數小時的互聯網搜索以尋找解決方案后,我還沒有接近它。 依賴在gradle中管理,spring boot版本為2.2.4.RELEASE:

implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'

runtimeOnly('org.springframework.cloud:spring-cloud-gcp-starter-sql-postgresql:1.2.1.RELEASE')
runtimeOnly('com.h2database:h2')

compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'

testImplementation('org.springframework.boot:spring-boot-starter-test')
implementation 'org.springframework.boot:spring-boot-starter-data-neo4j'
implementation 'org.springframework.boot:spring-boot-starter-data-rest'
implementation 'org.springframework.boot:spring-boot-devtools'
compile 'org.neo4j:neo4j:4.0.0'
compile 'org.neo4j:neo4j-ogm-bolt-driver'

application.properties 看起來像這樣

spring.data.neo4j.uri=bolt://34.76.157.40:7687
spring.data.neo4j.username=neo4j
spring.data.neo4j.password=******

我已經嘗試回退neo4j的版本,因為我們並不特別需要4.0.0,但這不起作用。 我的項目中沒有配置類,這個問題與我相信的注釋無關,因為它在本地工作。

任何遇到相同問題或可能會提供幫助的人?

對於我自己的應用程序,這花費了我相當長的時間來弄清楚。 所以這對我有用。

我在 Aura 和 Spring Data neo4j 6.1.6 上使用 neo4j 4.3.0

在這種情況下,您需要將 neo4j-java-driver-spring-boot-starter 添加到您的 Maven 依賴項中:

<dependency>
    <groupId>org.neo4j.driver</groupId>
    <artifactId>neo4j-java-driver-spring-boot-starter</artifactId>
    <version>4.2.7.0</version>
</dependency>

然后在 application.properties 中配置您的驅動程序設置,如下所示:

org.neo4j.driver.uri=neo4j+s://xxxxxx.databases.neo4j.io
org.neo4j.driver.authentication.username=neo4j
org.neo4j.driver.authentication.password=your_password
org.neo4j.driver.config.encrypted=true

這篇文章給我帶來了解決方案。 您還可以在那里找到舊版本和不同配置的信息。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM