与许多拥有Simlar Problem的人一样,我无法让我的插件扩展显示:
{
"extensions" : {
},
"node" : ...
}
使用java 1.7编译GetAll.java。使用SBT,build.sbt:
javaOptions ++= Seq( "-source", "1.7" )
libraryDependencies ++= Seq(
"org.neo4j" % "neo4j" % "2.1.3" % "provided" withSources(),
"org.neo4j" % "server-api" % "2.1.3" % "provided" withSources()
)
非常简单的JAR:
META-INF/
META-INF/MANIFEST.MF
META-INF/services/
META-INF/services/org.neo4j.server.plugins.ServerPlugin
GetAll.class
简单的GetAll.class:
package com.danmacias.neo4j.plugin;
import java.util.ArrayList;
import java.util.List;
import org.neo4j.graphdb.GraphDatabaseService;
import org.neo4j.graphdb.Node;
import org.neo4j.graphdb.Relationship;
import org.neo4j.graphdb.Transaction;
import org.neo4j.server.plugins.Description;
import org.neo4j.server.plugins.Name;
import org.neo4j.server.plugins.PluginTarget;
import org.neo4j.server.plugins.ServerPlugin;
import org.neo4j.server.plugins.Source;
import org.neo4j.tooling.GlobalGraphOperations;
// START SNIPPET: GetAll
package com.danmacias.neo4j.plugin;
import java.util.ArrayList;
import java.util.List;
@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 )
{
ArrayList<Node> nodes = new ArrayList<>();
try (Transaction tx = graphDb.beginTx())
{
for ( Node node : GlobalGraphOperations.at( graphDb ).getAllNodes() )
{
nodes.add( node );
}
tx.success();
}
return nodes;
}
}
META-INF /服务/ org.neo4j.server.plugins.ServerPlugin:
com.danmacias.neo4j.plugin.GetAll
(请注意结束换行符)
使用neo4j 2.0.2 java版&#34; 1.7.0_71&#34; Java(TM)SE运行时环境(版本1.7.0_71-b14) Java HotSpot(TM)64位服务器VM(内置24.71-b01,混合模式)
这个问题让我陷入疯狂的境地:S
答案 0 :(得分:0)
你的GetAll类应该在Jar中的目录中:
com/danmacias/neo4j/plugin/GetAll.class
通常像打包的Java jar一样。