带有Neo4j 2.2x的SDN [英] SDN with Neo4j 2.2x

查看:113
本文介绍了带有Neo4j 2.2x的SDN的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

Many are claiming that the SDN version 3.3.1 or 4.0.0.RC1 should work with neo4j 2.2.x but I could not make it to work.

我有这个spring配置配置:

I have this spring config configuration:

<?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中已被淘汰:

Looking in the code makes it clear: SDN refers to a class in neo4j library that was eliminated in 2.2.x:

org.neo4j.kernel.impl.nioneo.store.StoreId

在这种情况下,我有什么选择?

What are my options in this case?

推荐答案

尝试使用此Java配置文件而不是XML配置.

Try this Java configuration file instead of XML configuration.

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();
    }
}

这篇关于带有Neo4j 2.2x的SDN的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆