1

我是 SDN 新手,我正在尝试使用休眠进行跨存储持久性。网站上给出的教程有相同的例子,我也检查了 github 的。我有两个问题

  1. 我无法进行文档或示例中提到的 xml 配置。<neo4j:config/>不支持entityManagerFactory。我的假设是它创建了默认的Neo4jConfiguration,它没有用于entityManagerFactory. 我发现的解决方法是定义一个CrossStoreNeo4jConfiguration bean。

    @Bean
    public CrossStoreNeo4jConfiguration crossStoreNeo4jConfiguration(){
    CrossStoreNeo4jConfiguration configuration = new CrossStoreNeo4jConfiguration();
    configuration.setEntityManagerFactory(entityManagerFactory);
    configuration.setGraphDatabaseService(graphDatabaseService);
    return configuration;
    }
    

    如何在里面做到这一点<neo4j:config/>

  2. neo4j-template-ref当您使用定义存储库时将 Neo4jTemplate 引用到您的存储库时会发生什么neo4j:repositories?什么目的?

UDPATE

它无法创建的原因是CrossStoreNeo4jConfiguration<neo4j:config/> was缺少依赖 spring-data-neo4j-cross-store 。但是现在我在应用程序启动时遇到异常。

Caused by: java.lang.IllegalStateException: Singleton 'nodeEntityStateFactory' isn't currently in creation
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.afterSingletonCreation(DefaultSingletonBeanRegistry.java:312)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:239)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:292)
at org.springframework.data.neo4j.cross_store.config.CrossStoreNeo4jConfiguration$$EnhancerByCGLIB$$779c5955.nodeEntityStateFactory(<generated>)
at org.springframework.data.neo4j.config.Neo4jConfiguration.mappingContext(Neo4jConfiguration.java:199)
at org.springframework.data.neo4j.cross_store.config.CrossStoreNeo4jConfiguration$$EnhancerByCGLIB$$779c5955.CGLIB$mappingContext$11(<generated>)
at org.springframework.data.neo4j.cross_store.config.CrossStoreNeo4jConfiguration$$EnhancerByCGLIB$$779c5955$$FastClassByCGLIB$$3134c8a8.invoke(<generated>)
at net.sf.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228)
at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:280)
at org.springframework.data.neo4j.cross_store.config.CrossStoreNeo4jConfiguration$$EnhancerByCGLIB$$779c5955.mappingContext(<generated>)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:149)

提前致谢。

4

1 回答 1

1

这应该有效:

<neo4j:config entityManagerFactory="entityManagerFactory"/>

无需创建您的自定义实现。

传递给存储库配置的模板是其基础架构使用的模板。在大多数情况下,不需要配置不同的东西。

于 2012-09-05T20:00:02.767 回答