如何使用 AgensGraph 作为 Spring Boot 的 Neo4j 替代品?

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

考虑到使用 Neo4j 的 Spring-Boot 应用程序,我想用 AgensGraph 替换 Neo4j。但到目前为止,在尝试集成测试时,我还没有成功。

我的测试初始化代码如下

@ExtendWith(SpringExtension::class)
@ActiveProfiles("test")
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@Testcontainers
class FullStackTest {
    companion object {
        @Container
        val agensgraph = GenericContainer(
            "bitnine/agensgraph:v2.1.3"
        ).withExposedPorts(
            5432
        ).withEnv(
            "POSTGRES_PASSWORD", "agensgraph"
        )

        @BeforeAll
        @JvmStatic
        @Suppress("unused")
        fun neo4jProperties() {
            agensgraph.start()
            val uri = String.format("bolt://" + agensgraph.host + ":" + agensgraph.getMappedPort(5432))
            System.setProperty("spring.neo4j.uri", uri)
            System.setProperty("spring.neo4j.authentication.username", "postgres")
            System.setProperty("spring.neo4j.authentication.password", "agensgraph")
        }
    }


    // ... tests ...
}

运行它会导致以下错误:

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.

我做错了什么还是只是不兼容?

spring-boot spring-data-neo4j testcontainers agens-graph
1个回答
0
投票

不幸的是,AgensGraph 不支持 Neo4J 使用的 Bolt 协议。作为 PostgreSQL 扩展,它需要使用 PostgreSQL 协议。

启动 AgensGraph 实例后:

docker run -p 5432:5432 -e POSTGRES_HOST_AUTH_METHOD=trust -it --rm bitnine/agensgraph:latest

我可以使用

psql -h localhost -p 5432 -U postgres
连接到它,但是当我尝试
cypher-shell -a neo4j://localhost:5432
时它失败了,我在 AgensGraph 输出中得到了这个:

2024-04-23 08:22:41.826 UTC [58] LOG:  invalid length of startup packet
© www.soinside.com 2019 - 2024. All rights reserved.