我是SDN新手,我正在尝试使用hibernate进行跨存储持久化。在网站中给出的tutorial有相同的例子,我也检查了github的。我有两个问题Spring Data Neo4j - 跨存储持久性
我无法执行文档或示例中提到的xml配置。
<neo4j:config/>
不支持entityManagerFactory
。我的假设是它创建了缺省Neo4jConfiguration,它没有为entityManagerFactory
设置setter。我找到的解决方法是定义一个CrossStoreNeo4jConfiguration bean。@Bean public CrossStoreNeo4jConfiguration crossStoreNeo4jConfiguration(){ CrossStoreNeo4jConfiguration configuration = new CrossStoreNeo4jConfiguration(); configuration.setEntityManagerFactory(entityManagerFactory); configuration.setGraphDatabaseService(graphDatabaseService); return configuration; }
如何做到这里面
<neo4j:config/>
当你提到一个Neo4jTemplate到你的仓库使用
neo4j-template-ref
当你使用neo4j:repositories
定义库,会发生什么?什么目的?
UDPATE
它无法创建CrossStoreNeo4jConfiguration
与<neo4j:config/> was
究其原因,我缺少的依赖弹簧数据的Neo4j交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)
在此先感谢。
当使用该java.lang.IllegalStateException时,我得到这个异常:Singleton'nodeEntityStateFactory'目前尚未创建。我已经用完整的堆栈跟踪更新了我的问题。 – shazinltc
你使用哪个春天版本?你能更新到3.1.0.RELEASE吗? –
我正在使用3.1 .. – shazinltc