繁体   English   中英

如何配置Spring Boot应用程序以连接到Heroku上的GrapheneDB?

[英]How to configure a Spring Boot application to connect to GrapheneDB on Heroku?

配置Spring Boot应用程序以连接到Heroku上的GrapheneDB的最佳方法是什么? 我的spring boot应用程序已配置为与本地安装的neo4j连接,将应用程序和数据集部署在graphenedb上后,没有任何反应。 我相信我必须在application.properties文件上进行一些更改,但是我不知道该怎么做。 目前,我的application.properties文件看起来像这样,

#neo4j
spring.data.neo4j.username=neo4j
spring.data.neo4j.password=2bernadette
spring.data.neo4j.repositories.enabled=true
spring.data.neo4j.open-in-view=false

提前致谢

经过四天的研究,我发现,连接到GrapheneDB的最佳方法是使用http驱动程序。

因此,您必须在pom文件上添加依赖项,

<dependency>
        <scope>runtime</scope>
        <groupId>org.neo4j</groupId>
        <artifactId>neo4j-ogm-http-driver</artifactId>
        <version>${neo4j-ogm.version}</version>
</dependency>

然后,您需要将此配置包括在应用程序类中(放置主方法的位置)。 请把它放在前面

@Bean
public org.neo4j.ogm.config.Configuration getConfiguration() {
    org.neo4j.ogm.config.Configuration config = new org.neo4j.ogm.config.Configuration();
    config
            .driverConfiguration()
            .setDriverClassName("org.neo4j.ogm.drivers.http.driver.HttpDriver")
            .setURI("GRAPHENEDB_URL"); //Replace this string with the real url in quotes
    return config;
}

您应该导入org.neo4j.ogm.config.Configuration,但是为了避免歧义,它是这样做的。

在那之后,你应该没事。 :)

您也可以通过Bolt协议进行连接。 可以通过在Heroku CLI中键入以下命令来找到其凭据:

heroku config:get GRAPHENEDB_BOLT_URL
heroku config:get GRAPHENEDB_URL
heroku config:get GRAPHENEDB_USER
heroku config:get GRAPHENEDB_PASSWORD

然后只需输入您进入application.properties文件的信息,例如:

spring.data.neo4j.uri=<BOLT_URI>
spring.data.neo4j.username=<USERNAME>
spring.data.neo4j.password=<PASSWORD>

而且您已经准备就绪。

资料来源: https : //devcenter.heroku.com/articles/graphenedb

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM