有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java@PluginTarget(Node.class)未注册为neo4j插件

下面的简单类不会显示为插件

package com.danmacias.neoneoteplugin;

import java.util.ArrayList;
import java.util.List;

import org.neo4j.graphdb.*;
import org.neo4j.server.plugins.*;
import org.neo4j.graphalgo.*;
//import org.neo4j.tooling.GlobalGraphOperations;

@Description( "An extension to the Neo4j Server for getting all nodes or relationships" )
public class GetPaths extends ServerPlugin
{
  @Name( "breadth_first_paths" )
  @Description( "Breadth First Traversal of a specific node." )
  @PluginTarget( Node.class )
  public Iterable<Path> getPaths( @Source Node graphDb )
  {
    ArrayList<Path> paths = new ArrayList<>();
    return paths;
  }
}

卷曲返回

{                                                                                                                              
  "extensions" : {
    "GetAll" : {
      "get_all_nodes" : "http://localhost:7474/db/data/ext/GetAll/graphdb/get_all_nodes"
    }
    ...
},

但是当我替换节点的两个Instance时。使用GraphDatabaseService初始化。类,它可以很好地识别插件。为什么它不接受节点

此外,/var/logs/neo4j没有显示与此相关的任何错误


共 (1) 个答案

  1. # 1 楼答案

    不是100%确定,但我认为通过使用@PluginTarget(Node.class)锚定在节点级别的插件不会出现在全局扩展中。相反,当通过REST API检索节点时,会有一个extensions块,也指基于节点的插件