java - 安装 Neo4j REST 服务器插件

标签 java rest plugins amazon-ec2 neo4j

我正在尝试基于 http://docs.neo4j.org/chunked/snapshot/server-plugins.html 为 Neo4j REST 服务器创建示例服务器插件

我使用 Neo4j 1.7.2 CE Ubuntu 12.04 64 位 (ami-f3c8679a) 设置了 Amazon EC2 实例,它正在工作 - 在尝试获取 MyEC2DNS:7474 时,我得到了正确的响应/db/data 所以服务器没问题。

eclipse 中

  • 创建了新的 Java 项目
  • 创建了 libs 文件夹并复制了下载的 1.7.2 Neo4j Community Edition 中的所有文件 - neo4j-community-1.7.2/lib 并将它们添加到构建路径
  • 包 com.neo4j.server.plugins.example 中使用内容创建了示例类

代码(来自https://github.com/neo4j/community/blob/master/server-examples/src/main/java/org/neo4j/examples/server/plugins/GetAll.java)

@Description("An extension to the Neo4j Server for getting all nodes or relationships")
public class GetAll extends ServerPlugin {

    @Name("get_all_nodes")
    @Description("Get all nodes from the Neo4j graph database")
    @PluginTarget( GraphDatabaseService.class)
    public Iterable<Node> getAllNodes(@Source GraphDatabaseService graphDb) {
        return GlobalGraphOperations.at(graphDb).getAllNodes();
    }

    @Description("Get all relationships from the Neo4j graph database")
    @PluginTarget(GraphDatabaseService.class)
    public Iterable<Relationship> getAllRelationships(@Source GraphDatabaseService graphDb) {
        return GlobalGraphOperations.at(graphDb).getAllRelationships();
    }
}
  • 在 Eclipse 中,在 META-INF/services 内创建了文件 org.neo4j.server.plugins.ServerPlugin,其中包含单行 com.neo4j.server.plugins。示例.GetAll
  • 位于 Java 项目文件夹中并执行 jar -cvf get_all.jar * - 我得到了 ~13Mb .jar 文件
  • 将其复制到我的 Amazon EC2 实例 /opt/neo4j/neo4j-community-1.7.2/plugins
  • 使用 sudo -u neo4j ./bin/neo4j restart 重新启动 Neo4j 服务器
  • 我得到的是

回应

Stopping Neo4j server [1718].... done
./bin/neo4j: line 174: ulimit: open files: cannot modify limit: Operation not permitted
Starting Neo4j Server...WARNING: not chaning user
process [1891]... waiting for server to be ready...... OK

当我获取 MyEC2DNS:7474/db/data 时,扩展程序仍然不可见。

想法?我的猜测是,也许这个插件太大了(不需要包含所有这些 .jar,但另一种方法是什么 - 将它们放在相对路径中,如何?)。

最佳答案

已解决,所有步骤与问题中的相同,除了

位于 Java 项目文件夹中并执行 jar -cvf get_all.jar * - 我得到了 ~13Mb .jar 文件

应该是

- 在 Eclipse 中转到文件 - 导出 - JAR - 导出除“lib”文件夹之外的所有内容

然后它就可以完美工作了,当然插件本身只有 ~100 kB。

关于java - 安装 Neo4j REST 服务器插件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12329870/

相关文章:

java - Payara 5 与 Java 9 的兼容性

java.lang.NoClassDefFoundError : org/w3c/tidy/Tidy , Maven项目

java - 扫描仪在使用 next() 或 nextFoo() 后跳过 nextLine()?

json - GitHub API 中的 blob_url、raw_url 和 contents_url 有什么区别?

rest - 如何使用 JAXB 使用 Jersey 1.17.1 生成 JSON 输出

java - Matlab中多行注释的正则表达式

java - 运行时的部分 JSON 序列化(用于 RESTful 查询)

.NET:将程序集绑定(bind)到引用程序集的新版本,无需重新编译

eclipse - 我在新安装的 Eclipse 中找不到插件项目?帮助

java - JMeter 中的哪个类从 lib/ext 文件夹中的插件读取类?