neo4j自定义过程与函数安装到plugins时重启报错
发布于 5 个月前 作者 crazyyanchao 378 次浏览 来自 问答

想请教一下这个报错是什么原因引起的? TIM截图21111111111111111111111110180803154501.png 修改pom.xml:

 <dependencies>

        <dependency>
            <groupId>org.neo4j</groupId>
            <artifactId>neo4j</artifactId>
            <version>3.4.1</version>
        </dependency>
        <dependency>
            <groupId>org.neo4j.test</groupId>
            <artifactId>neo4j-harness</artifactId>
            <version>3.4.1</version>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.12</version>
        </dependency>

    </dependencies>

    <build>
        <plugins>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.1</version>
                <configuration>
                    <!-- Neo4j Procedures require Java 8 -->
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
            <plugin>
                <!-- This generates a jar-file with our procedure code,
                     plus any dependencies marked as `compile` scope.
                     This should then be deployed in the `plugins` directory
                     of each Neo4j instance in your deployment.
                     After a restart, the procedure is available for calling. -->
                <artifactId>maven-shade-plugin</artifactId>
                <version>2.4.3</version>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

之后重新启动报错:

222222222222220180803170052.png

9 回复

提示说你@userFunction后没加命名空间,请改为@userFunction(com.xxxxxx.xxx)试试

@pangguoming 我加的是这样procedures是当前类的包名,完整包名是com.***.procedures

@UserFunction( name = “procedures.hello”)

通过修改pom.xml文件解决了,pom.xml如下:


    <properties>
        <neo4j.version>3.4.1</neo4j.version>
    </properties>

    <dependencies>
        <dependency>
            <!-- This gives us the Procedure API our runtime code uses.
                 We have a `provided` scope on it, because when this is
                 deployed in a Neo4j Instance, the API will be provided
                 by Neo4j. If you add non-Neo4j dependencies to this
                 project, their scope should normally be `compile` -->
            <groupId>org.neo4j</groupId>
            <artifactId>neo4j</artifactId>
            <version>${neo4j.version}</version>
            <scope>provided</scope>
        </dependency>

        <!-- Test Dependencies -->
        <dependency>
            <!-- This is used for a utility that lets us start Neo4j with
                 a specific Procedure, which is nice for writing tests. -->
            <groupId>org.neo4j.test</groupId>
            <artifactId>neo4j-harness</artifactId>
            <version>${neo4j.version}</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <!-- Used to send cypher statements to our procedure. -->
            <groupId>org.neo4j.driver</groupId>
            <artifactId>neo4j-java-driver</artifactId>
            <version>1.4.2</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.12</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.1</version>
                <configuration>
                    <!-- Neo4j Procedures require Java 8 -->
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
            <plugin>
                <!-- This generates a jar-file with our procedure code,
                     plus any dependencies marked as `compile` scope.
                     This should then be deployed in the `plugins` directory
                     of each Neo4j instance in your deployment.
                     After a restart, the procedure is available for calling. -->
                <artifactId>maven-shade-plugin</artifactId>
                <version>2.4.3</version>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

我是 创建的JAVA包名为:com.pangguoming.neo4j,然后@userFunction(com.pangguoming.neo4j) 完全一致,没有问题的,你都改成com.xxx.xxx这样试试

@pangguoming 请教一下,过程与函数有什么区别和联系?现在直到如何自定义过程和函数了,但是它们的本质还是没有搞清楚!能否详细解释一下?

@pangguoming 我有些查询比较慢,能否使用自定义函数优化?能否分享更多的自定义过程和函数的例子?

过程就是用 Call com.xxxx.xx (参数)来调用执行。 方法就是 可以用在 cypher中任何可以使用方法的地方如 where字句 return字句 中 如match (n) wehre com.xxx.xx(n) return n

可以发一个完成的项目吗? 我在写自定义存储过程的时候老是报错,想和你的对比一下。

他的视频里面有

回到顶部