spring-data-neo4j - 带有 Neo4j 2.2x 的 SDN

标签 spring-data-neo4j

许多人声称 SDN 版本 3.3.1 或 4.0.0.RC1 应该与 neo4j 2.2.x 一起工作,但我无法使其工作。

我有这个 Spring 配置配置:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:neo4j="http://www.springframework.org/schema/data/neo4j"
    xmlns:tx="http://www.springframework.org/schema/tx"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
        http://www.springframework.org/schema/data/neo4j http://www.springframework.org/schema/data/neo4j/spring-neo4j-2.2.xsd
        http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd">

    <context:annotation-config />
    <context:spring-configured />

    <neo4j:config graphDatabaseService="graphDatabaseService" base-package="com.x.protogy.neo4j"/>
    <bean id="graphDatabaseService"
        class="org.springframework.data.neo4j.rest.SpringCypherRestGraphDatabase">
      <constructor-arg index="0" value="http://localhost:7476/db/data" />
    </bean>
    <tx:annotation-driven mode="aspectj"
        transaction-manager="transactionManager" />

</beans>

这会产生这个异常:
Caused by: java.lang.ClassNotFoundException: org.neo4j.kernel.impl.nioneo.store.StoreId
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1324)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1177)

查看代码很清楚:SDN指的是neo4j库中的一个在2.2.x中被淘汰的类:
org.neo4j.kernel.impl.nioneo.store.StoreId

在这种情况下我有哪些选择?

最佳答案

试试这个 Java 配置文件而不是 XML 配置。

import org.neo4j.ogm.session.Session;
import org.neo4j.ogm.session.SessionFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;


@Configuration
@EnableNeo4jRepositories("com.app.repository")
@EnableTransactionManagement
@ComponentScan("com.app")

public class AppNeo4jConfiguration extends Neo4jConfiguration{


    public SessionFactory getSessionFactory() {
        return new SessionFactory("com.app.bo");
    }


    @Bean
    public Neo4jServer neo4jServer() {
        return new RemoteServer("http://localhost:7474");
    }


    @Bean
    @Scope(value = "session", proxyMode = ScopedProxyMode.TARGET_CLASS)
    public Session getSession() throws Exception {
        return super.getSession();
    }
}

关于spring-data-neo4j - 带有 Neo4j 2.2x 的 SDN,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31510052/

相关文章:

spring-data-neo4j - 非关系属性未在 Spring Data Rest Neo4j 输出中的引用实体上公开

java - Spring Data Neo4j 和查询

java - Spring 数据 neo4j LIKE 查询不起作用

java - cypher 上的索引不会在事务中更新

java - 如何使用 Spring Data Neo4j 指定查询的深度?

spring-boot - 如何使用spring-data-neo4j和Grails 3.3.6解决Spring bean冲突

session - SDN升级到4.2.0.BUILD-SNAPSHOT后如何获取当前的neo4j session ?

java - Neo4JTemplate 在一个查询中创建并获取 Id - Spring Data Neo4j 4.0.0.M1

java - 如何在 Neo4j 中使用 Using enum RelationshipType?