简体   繁体   English

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

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

What is the best way to configure a Spring Boot application to connect to GrapheneDB on Heroku? 配置Spring Boot应用程序以连接到Heroku上的GrapheneDB的最佳方法是什么? My spring boot application was configured to connect with my locally installed neo4j, after deploying the application and the dataset on graphenedb, nothing is working. 我的spring boot应用程序已配置为与本地安装的neo4j连接,将应用程序和数据集部署在graphenedb上后,没有任何反应。 I believe I have to make some changes on my application.properties file but I have no idea how to do it. 我相信我必须在application.properties文件上进行一些更改,但是我不知道该怎么做。 Currently my application.properties file looks like this, 目前,我的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

Thanks in advance 提前致谢

Well after four days researching, I was able to find out that the best way to connect to GrapheneDB is to use the http Driver. 经过四天的研究,我发现,连接到GrapheneDB的最佳方法是使用http驱动程序。

So you have to add a dependency on your pom file, 因此,您必须在pom文件上添加依赖项,

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

Then you need to include this configuration in your application class (Where you placed your main method). 然后,您需要将此配置包括在应用程序类中(放置主方法的位置)。 Kindly place it before, 请把它放在前面

@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;
}

You are supposed to import org.neo4j.ogm.config.Configuration but in order to avoid ambiguity, It made it this way. 您应该导入org.neo4j.ogm.config.Configuration,但是为了避免歧义,它是这样做的。

After that, you should be fine. 在那之后,你应该没事。 :) :)

You can also connect via Bolt Protocol. 您也可以通过Bolt协议进行连接。 Its credentials can be found out by typing the following commands into Heroku CLI: 可以通过在Heroku CLI中键入以下命令来找到其凭据:

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

Then just enter the info you got into application.properties file, such as: 然后只需输入您进入application.properties文件的信息,例如:

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

And you're pretty much all set. 而且您已经准备就绪。

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

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

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