我是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