Как и многие люди с проблемой Simlar, я не могу получить расширение своего плагина:
{
"extensions" : {
},
"node" : ...
}
Скомпилированный GetAll.java с использованием java 1.7. Используя 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-версия "1.7.0_71" Java (TM) SE Runtime Environment (build 1.7.0_71-b14) 64-разрядная серверная виртуальная машина Java HotSpot TM (сборка 24.71-b01, смешанный режим)
Эта проблема заставила меня на пороге сойти с ума: S
Ваш класс GetAll должен находиться в каталоге в Jar:
com/danmacias/neo4j/plugin/GetAll.class
Как обычно, Java-пакеты упакованы.