我正在尝试基于 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
中使用内容创建了示例类
@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/