【问题标题】:How To Use Grails With GrapheneDB如何在 GrapheneDB 中使用 Grails
【发布时间】:2014-03-06 14:34:14
【问题描述】:

有人在 Grails 项目中使用过 Graphenedb 吗?我正在尝试创建一个托管在 Appfog 中的 Neo4J 应用程序,我将连接到 GrapheneDB 中的 Neo4J DB,但我似乎什至无法弄清楚如何在 Grails 中启动 Neo4J。我做了以下事情:

  1. 在 Grails Tool Suite 中创建了新的 Grails 2.3.5 项目

  2. 在 BuildConfig 中,移除 hibernate 引用然后添加:

    存储库 { mavenRepo 'http://m2.neo4j.org/releases'

    plugins {compile ":neo4j:1.1.1" //遵循 Grails Neo4J GORM 指令

    compile("org.neo4j:neo4j-rest-graphdb:1.6") //也试过 2.0.0

  3. 在数据源中添加:

    grails { neo4j { 类型=“休息” location = "xxx.sb01.stations.graphenedb.com:xxxx/db/data"

  4. 使用静态 mapWith = "neo4j" 创建域类并生成控制器和视图

无论我做什么,都会出错:

解决获取依赖项的错误:在 grailsCentral 中找不到工件 org.neo4j:neo4j-rest-graphdb:jar:xxx

编译错误:启动失败:使用javac编译时出现编译错误..

其他人对带有 Grails 的 Neo4J 有疑问:

Error loading Neo4j from grails app

grails unable to connect to neo4j datastore

问题:

  1. 是否有关于如何在 Grails 上设置 Neo4j rest 的教程?

  2. 对于 Neo4J 来说,使用 Play 框架是否比使用 Grails 更好?在 Scala 中构建 Neo4J 应用程序的示例似乎比 Grails 更多。 http://www.neo4j.org/develop/scala

【问题讨论】:

    标签: grails neo4j


    【解决方案1】:

    我是来自GrapheneDB 的 Alberto。

    我知道您似乎遇到了编译错误。我对 Grails 不熟悉,因此无法真正帮助您。

    我相信您的 DataSource 配置 sn-p 将不起作用,因为连接到 GrapheneDB 实例需要提供身份验证凭据。

    我不确定您是否可以像这样提供嵌入在 URL 中的凭据:

    grails {
        neo4j {
            type = "rest"
            location = "http://username:password@fqdn:port/db/data/"
        }
    }
    

    或者,如果您必须提供用户名和密码作为单独的配置参数:

    grails {
        neo4j {
            type = "rest"
            location = "fqdn:port/db/data/"
            login = "login"
            password = "password" 
        }
    }
    

    如果您设法克服编译错误,您愿意分享您为使其正常工作所经历的步骤吗?对于希望将 Grails 应用程序与 GrapheneDB 连接的任何人,我想将它们包含在文档中。

    阿尔贝托。

    【讨论】:

      【解决方案2】:

      https://github.com/sarmbruster/neo4jsample 有一个小型演示应用程序,我已验证它可以与 GrapheneDB 一起使用。

      诀窍是使用环境变量NEO4_HOSTNEO4J_USERNEO4J_LOGINNEO4J_PASSWORD指定远程数据库,并在grails-app/conf/DataSource.groovy中使用type=rest

      请注意,如果您对 Grails 2.3.x 使用分叉模式,您会收到 ClassNotFoundExecption。解决方法是关闭运行环境的分叉模式。

      【讨论】:

      • Datasource.groovy 中 NEO4J_USER 等的正确语法是什么?我尝试了 Alberto 的建议,还尝试将 NEO4J_USER = "user" 等置于环境下,但仍然无法访问 GrapheneDB。
      【解决方案3】:

      @jun yoga 语法应该是这样的

      export NEO4J_HOST="" #e.g.neo4jsample.sb01.stations.graphenedb.com"

      导出 NEO4J_LOGIN=""#REST 用户名

      导出 NEO4J_PASSWORD=""#REST PASSWORD

      导出 NEO4J_PORT=""#xxxxx

      如果您使用的是 linux,则应在终端中输入。它是系统环境变量而不是应用程序环境:)

      【讨论】:

        猜你喜欢
        • 2020-11-27
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2015-06-15
        • 2016-07-02
        • 2013-06-27
        • 2017-11-02
        • 2015-10-02
        相关资源
        最近更新 更多