由于以下原因,我无法配置TypeRepresentationStrategy
:
无法将'org.neo4j.kernel.EmbeddedGraphDatabase'类型的值转换为所需类型'org.springframework.data.neo4j.core.GraphDatabase';
我使用Spring-Data-Neo4j 3.1.4和Neo4j 2.1.2。
这是因为我在spring-context配置中定义的graphDatabaseService
实例是EmbeddedGraphDatabase
的类型,请参阅我的配置:
<util:map id="config">
<entry key="remote_shell_enabled" value="true"/>
<entry key="cache-type" value="weak"/>
</util:map>
<bean id="graphDbFactory" class="org.neo4j.graphdb.factory.GraphDatabaseFactory"/>
<bean id="graphDbBuilder" factory-bean="graphDbFactory" factory-method="newEmbeddedDatabaseBuilder">
<constructor-arg value="target/neo4j-db-plain"/>
</bean>
<bean id="graphDbBuilderFinal" factory-bean="graphDbBuilder" factory-method="setConfig">
<constructor-arg ref="config"/>
</bean>
<bean id="graphDatabaseService" factory-bean="graphDbBuilderFinal" factory-method="newGraphDatabase"
destroy-method="shutdown"/>
<bean id="serverWrapper" class="org.neo4j.server.WrappingNeoServerBootstrapper" init-method="start"
destroy-method="stop">
<constructor-arg ref="graphDatabaseService"/>
</bean>
<neo4j:config base-package="com.hobbydeed.graph.model" graphDatabaseService="graphDatabaseService" />
<bean id="typeRepresentationStrategyFactory" class="org.springframework.data.neo4j.support.typerepresentation.TypeRepresentationStrategyFactory">
<constructor-arg index="0" ref="graphDatabaseService"/>
<constructor-arg type="org.springframework.data.neo4j.support.typerepresentation.TypeRepresentationStrategyFactory.Strategy">
<value>Indexed</value>
</constructor-arg>
</bean>
问题是如何在TypeRepresentation
org.neo4j.kernel.EmbeddedGraphDatabase
implements
时将org.neo4j.graphdb.GraphDatabaseService
配置为“已建立索引”,但TypeRepresentationFactory
想要org.springframework.data.neo4j.core.GraphDatabase
?< / p>
答案 0 :(得分:0)
您可以使用所选策略覆盖nodeTypeRepresentationStrategy
bean。
对于您使用的策略工厂,您只需使用&#34; graphDatabase&#34; bean参考。
或者您使用DelegatingGraphDatabase(graphDatabaseService)
作为graphDatabase
的bean,这是默认值。