我正在尝试配置我的应用程序上下文,以便能够在我的应用程序中使用带有嵌入式图形的 Neo4j 服务器,但没有取得多大成功。我同时使用 Spring Data(Mongo 和 Neo4j 存储库方法)。这是我的应用程序上下文,它没有运行:
<context:component-scan base-package="org.domain.team.project.*"/>
<mongo:repositories base-package="org.domain.team.project.data.repositories.mongodb"/>
<!-- Neo4j -->
<!-- <neo4j:config storeDirectory="/data/production/graph.db"/> -->
<neo4j:repositories base-package="org.domain.team.project.data.repositories.neo4j"/>
<neo4j:config graphDatabaseService="graphDatabaseService" />
<bean id="graphDatabaseService" class="org.neo4j.kernel.EmbeddedGraphDatabase"
destroy-method="shutdown">
<constructor-arg index="0" value="/data/production/graph.db" />
<constructor-arg index="1">
<map><entry key="enable_remote_shell" value="true"/></map>
</constructor-arg>
</bean>
<bean id="serverWrapper" class="org.neo4j.server.WrappingNeoServerBootstrapper"
init-method="start" destroy-method="stop">
<constructor-arg ref="graphDatabaseService"/>
</bean>
如果我不使用这种方法并简单地指定存储目录(注释行),一切运行正常。我怀疑这是 SDN 和 neo4j-server 问题之间的一个版本。这是我的POM:
<properties>
<spring.data.mongo.version>1.1.0.RELEASE</spring.data.mongo.version>
<spring.data.neo4j.version>2.1.0.RELEASE</spring.data.neo4j.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-mongodb</artifactId>
<version>${spring.data.mongo.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-neo4j</artifactId>
<version>${spring.data.neo4j.version}</version>
</dependency>
<dependency>
<groupId>org.neo4j.app</groupId>
<artifactId>neo4j-server</artifactId>
<version>1.8.2</version>
</dependency>
<dependency>
<groupId>org.neo4j.app</groupId>
<artifactId>neo4j-server</artifactId>
<classifier>static-web</classifier>
<version>1.8.2</version>
</dependency>
</dependencies>
它的父级依赖 Spring(core,context,test) 3.2.0 Release。
显示的具体错误是:
Caused by: java.lang.NoSuchFieldError: query_cache_size
at org.neo4j.cypher.ExecutionEngine.org$neo4j$cypher$ExecutionEngine$$getQueryCacheSize(ExecutionEngine.scala:95)
at org.neo4j.cypher.ExecutionEngine$$anon$1.<init>(ExecutionEngine.scala:91)
at org.neo4j.cypher.ExecutionEngine.<init>(ExecutionEngine.scala:91)
at org.neo4j.cypher.javacompat.ExecutionEngine.<init>(ExecutionEngine.java:54)
at org.neo4j.cypher.javacompat.ExecutionEngine.<init>(ExecutionEngine.java:44)
at org.springframework.data.neo4j.support.query.CypherQueryEngine.<init>(CypherQueryEngine.java:42)
at org.springframework.data.neo4j.support.DelegatingGraphDatabase.createCypherQueryEngine(DelegatingGraphDatabase.java:217)
at org.springframework.data.neo4j.support.DelegatingGraphDatabase.queryEngineFor(DelegatingGraphDatabase.java:190)
at org.springframework.data.neo4j.support.MappingInfrastructureFactoryBean.afterPropertiesSet(MappingInfrastructureFactoryBean.java:146)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1545)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1483)
... 47 more
就我而言,这应该没问题,因为默认值为100。SDN 文档并没有过多谈论它。有什么建议么?
谢谢大家。