Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
java.lang.NoSuchMethodError:org.neo4j.kernel.impl.transaction.SpringTransactionManager;初始化>;(Lorg/neo4j/graphdb/GraphDatabaseService;)V_Spring_Neo4j_Spring Data Neo4j - Fatal编程技术网

java.lang.NoSuchMethodError:org.neo4j.kernel.impl.transaction.SpringTransactionManager;初始化>;(Lorg/neo4j/graphdb/GraphDatabaseService;)V

java.lang.NoSuchMethodError:org.neo4j.kernel.impl.transaction.SpringTransactionManager;初始化>;(Lorg/neo4j/graphdb/GraphDatabaseService;)V,spring,neo4j,spring-data-neo4j,Spring,Neo4j,Spring Data Neo4j,我开始学习spring-data-neo4j 我正在运行非常基本的测试用例,但无法成功。 错误为:java.lang.IllegalStateException:未能加载ApplicationContext Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'neo4jRelationshipBacking' defined in class path

我开始学习
spring-data-neo4j

我正在运行非常基本的测试用例,但无法成功。 错误为:
java.lang.IllegalStateException:未能加载ApplicationContext

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'neo4jRelationshipBacking' defined in class path resource [org/springframework/data/neo4j/aspects/config/Neo4jAspectConfiguration.class]: Instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: Factory method [public org.springframework.data.neo4j.aspects.support.relationship.Neo4jRelationshipBacking org.springframework.data.neo4j.aspects.config.Neo4jAspectConfiguration.neo4jRelationshipBacking() throws java.lang.Exception] threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'neo4jTemplate' defined in class path resource [org/springframework/data/neo4j/aspects/config/Neo4jAspectConfiguration.class]: Instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: Factory method [public org.springframework.data.neo4j.support.Neo4jTemplate org.springframework.data.neo4j.config.Neo4jConfiguration.neo4jTemplate() throws java.lang.Exception] threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mappingInfrastructure' defined in class path resource [org/springframework/data/neo4j/aspects/config/Neo4jAspectConfiguration.class]: Instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: Factory method [public org.springframework.data.neo4j.support.MappingInfrastructureFactoryBean org.springframework.data.neo4j.config.Neo4jConfiguration.mappingInfrastructure() throws java.lang.Exception] threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'neo4jTransactionManager' defined in class path resource [org/springframework/data/neo4j/aspects/config/Neo4jAspectConfiguration.class]: Instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: Factory method [public org.springframework.transaction.PlatformTransactionManager org.springframework.data.neo4j.config.Neo4jConfiguration.neo4jTransactionManager()] threw exception; nested exception is java.lang.NoSuchMethodError: org.neo4j.kernel.impl.transaction.SpringTransactionManager.<init>(Lorg/neo4j/graphdb/GraphDatabaseService;)V
配置文件为:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:context="http://www.springframework.org/schema/context"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:neo4j="http://www.springframework.org/schema/data/neo4j"
       xmlns:tx="http://www.springframework.org/schema/tx"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
        http://www.springframework.org/schema/data/neo4j http://www.springframework.org/schema/data/neo4j/spring-neo4j-2.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">

    <context:annotation-config/>
    <context:spring-configured/>

    <neo4j:config  storeDirectory="D:/data/db"/>
    <tx:annotation-driven mode="proxy"/>
    <context:component-scan base-package="com.neo4j.model"/>
</beans>
commons-logging-1.0.4.jar
log4j-1.2.15.jar
jta.jar
cglib-2.1.3.jar
validation-api-1.0.0.GA.jar
lucene-core-3.5.0.jar
servlet-api.jar
org.springframework.aop-3.1.2.RELEASE.jar
org.springframework.asm-3.1.2.RELEASE.jar
org.springframework.aspects-3.1.2.RELEASE.jar
org.springframework.beans-3.1.2.RELEASE.jar
org.springframework.context.support-3.1.2.RELEASE.jar
org.springframework.context-3.1.2.RELEASE.jar
org.springframework.core-3.1.2.RELEASE.jar
org.springframework.expression-3.1.2.RELEASE.jar
org.springframework.instrument.tomcat-3.1.2.RELEASE.jar
org.springframework.instrument-3.1.2.RELEASE.jar
org.springframework.jdbc-3.1.2.RELEASE.jar
org.springframework.jms-3.1.2.RELEASE.jar
org.springframework.orm-3.1.2.RELEASE.jar
org.springframework.oxm-3.1.2.RELEASE.jar
org.springframework.test-3.1.2.RELEASE.jar
org.springframework.transaction-3.1.2.RELEASE.jar
org.springframework.web.portlet-3.1.2.RELEASE.jar
org.springframework.web.servlet-3.1.2.RELEASE.jar
org.springframework.web.struts-3.1.2.RELEASE.jar
org.springframework.web-3.1.2.RELEASE.jar
D:\JUnit\junit-4.6.jar
com.springsource.org.aopalliance-1.0.0.jar
aspectjtools-1.6.0.jar
asm-attrs.jar
asm.jar
spring-data-neo4j-2.1.0.RC1.jar
spring-data-neo4j-aspects-2.1.0.RC1.jar
spring-data-neo4j-cross-store-2.1.0.RC1.jar
spring-data-neo4j-rest-2.1.0.RC1.jar
slf4j-api-1.6.1.jar
slf4j-log4j12-1.7.2.jar
geronimo-jta_1.1_spec-1.1.1.jar
lucene-core-3.5.0.jar
org.apache.servicemix.bundles.jline-0.9.94_1.jar
scala-library-2.9.0-1.jar
server-api-1.7.2.jar
spring-data-commons-core-1.3.1.RELEASE.jar
hamcrest-all-1.3.jar
neo4j-cypher-dsl-1.6.M02.jar
neo4j-cypher-1.9-20120912.103508-32.jar
neo4j-kernel-1.9-20120912.102607-33.jar
neo4j-lucene-index-1.9-20120912.103015-33.jar
我已经从eclipse构建路径手动添加了以下jar文件:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:context="http://www.springframework.org/schema/context"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:neo4j="http://www.springframework.org/schema/data/neo4j"
       xmlns:tx="http://www.springframework.org/schema/tx"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
        http://www.springframework.org/schema/data/neo4j http://www.springframework.org/schema/data/neo4j/spring-neo4j-2.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">

    <context:annotation-config/>
    <context:spring-configured/>

    <neo4j:config  storeDirectory="D:/data/db"/>
    <tx:annotation-driven mode="proxy"/>
    <context:component-scan base-package="com.neo4j.model"/>
</beans>
commons-logging-1.0.4.jar
log4j-1.2.15.jar
jta.jar
cglib-2.1.3.jar
validation-api-1.0.0.GA.jar
lucene-core-3.5.0.jar
servlet-api.jar
org.springframework.aop-3.1.2.RELEASE.jar
org.springframework.asm-3.1.2.RELEASE.jar
org.springframework.aspects-3.1.2.RELEASE.jar
org.springframework.beans-3.1.2.RELEASE.jar
org.springframework.context.support-3.1.2.RELEASE.jar
org.springframework.context-3.1.2.RELEASE.jar
org.springframework.core-3.1.2.RELEASE.jar
org.springframework.expression-3.1.2.RELEASE.jar
org.springframework.instrument.tomcat-3.1.2.RELEASE.jar
org.springframework.instrument-3.1.2.RELEASE.jar
org.springframework.jdbc-3.1.2.RELEASE.jar
org.springframework.jms-3.1.2.RELEASE.jar
org.springframework.orm-3.1.2.RELEASE.jar
org.springframework.oxm-3.1.2.RELEASE.jar
org.springframework.test-3.1.2.RELEASE.jar
org.springframework.transaction-3.1.2.RELEASE.jar
org.springframework.web.portlet-3.1.2.RELEASE.jar
org.springframework.web.servlet-3.1.2.RELEASE.jar
org.springframework.web.struts-3.1.2.RELEASE.jar
org.springframework.web-3.1.2.RELEASE.jar
D:\JUnit\junit-4.6.jar
com.springsource.org.aopalliance-1.0.0.jar
aspectjtools-1.6.0.jar
asm-attrs.jar
asm.jar
spring-data-neo4j-2.1.0.RC1.jar
spring-data-neo4j-aspects-2.1.0.RC1.jar
spring-data-neo4j-cross-store-2.1.0.RC1.jar
spring-data-neo4j-rest-2.1.0.RC1.jar
slf4j-api-1.6.1.jar
slf4j-log4j12-1.7.2.jar
geronimo-jta_1.1_spec-1.1.1.jar
lucene-core-3.5.0.jar
org.apache.servicemix.bundles.jline-0.9.94_1.jar
scala-library-2.9.0-1.jar
server-api-1.7.2.jar
spring-data-commons-core-1.3.1.RELEASE.jar
hamcrest-all-1.3.jar
neo4j-cypher-dsl-1.6.M02.jar
neo4j-cypher-1.9-20120912.103508-32.jar
neo4j-kernel-1.9-20120912.102607-33.jar
neo4j-lucene-index-1.9-20120912.103015-33.jar

看起来您使用的是旧的Neo4j版本。你能试试相应的Neo4j版本吗?我认为是1.8而不是1.7.2?

正如Peter所说,问题是你包含的Neo4j库的版本与Spring预期的不同。NoSuchMethodError表示客户端正在调用不存在的方法。如果包含Spring正在使用的版本,则不会发生这种情况,因为如果Spring调用了不存在的方法,则会出现编译错误

你如何构建你的项目?如果是maven项目,请提供更多细节,如POM


更新:org.neo4j.kernel.impl.transaction.SpringTransactionManager来自您的neo4j安装,而不是您提供的JAR。您正在运行哪一版本的Neo4J?它需要与spring-data-neo4j期望的版本相匹配。

最后,我使用以下jar文件解决了这个问题:

aopalliance-1.0.jar
asm-3.1.jar
aspectjrt-1.6.12.jar
backport-util-concurrent-3.1.jar
cglib-2.2.jar
codegen-0.5.5.jar
commons-cli-1.0.jar
ecj-3.7.2.jar
guava-11.0.2.jar
hamcrest-core-1.3.jar
hamcrest-library-1.3.jar
jakarta-regexp-1.4.jar
javax.inject-1.jar
jcl-over-slf4j-1.7.1.jar
jsr305-1.3.9.jar
jta.jar
junit-3.8.1.jar
junit-dep-4.10.jar
logback-classic-1.0.6.jar
logback-core-1.0.6.jar
lucene-core-3.5.0.jar
lucene-queries-3.5.0.jar
mysema-commons-lang-0.2.4.jar
neo4j-1.8.jar
neo4j-cypher-1.8.jar
neo4j-cypher-dsl-1.8.jar
neo4j-graph-algo-1.8.jar
neo4j-graph-matching-1.8.jar
neo4j-jmx-1.8.jar
neo4j-kernel-1.8.jar
neo4j-lucene-index-1.8.jar
neo4j-udc-1.8.jar
plexus-compiler-api-1.9.1.jar
plexus-compiler-javac-1.9.1.jar
plexus-compiler-manager-1.9.1.jar
plexus-interactivity-api-1.0-alpha-4.jar
plexus-interpolation-1.11.jar
plexus-interpolation-1.13.jar
plexus-utils-1.5.15.jar
plexus-utils-2.0.5.jar
plexus-utils-3.0.jar
querydsl-apt-2.8.2.jar
querydsl-codegen-2.8.2.jar
querydsl-core-2.8.2.jar
querydsl-lucene-2.8.2.jar
scala-library-2.9.1-1.jar
slf4j-api-1.7.1.jar
spring-aop-3.2.0.M2.jar
spring-aspects-3.2.0.M2.jar
spring-beans-3.2.0.M2.jar
spring-context-3.2.0.M2.jar
spring-core-3.2.0.M2.jar
spring-data-commons-core-1.4.0.RELEASE.jar
spring-data-neo4j-2.1.0.RELEASE.jar
spring-expression-3.2.0.M2.jar
spring-jdbc-3.2.0.M2.jar
spring-orm-3.2.0.M2.jar
spring-test-3.2.0.M2.jar
spring-tx-3.2.0.M2.jar
validation-api-1.0.0.GA.jar

我会尝试更新版本的spring-data-neo4j,比如spring-data-neo4j-2.1.0-RELEASE,甚至spring-data-neo4j-2.2.0.BUILD-snapshot谢谢@WernerVesterås你能给我下载的url吗。我找不到它。在添加spring-data-neo4j-2.2.0之后,我得到了java.lang.NoClassDefFoundError:org/springframework/data/repository/config/RepositoryConfigurationExtension这个错误。请帮助解决它。我更新了问题,请看一下…谢谢你的回答,即使我也尝试了neo4j 1.9。仍然会出现相同的错误…另一种确保获得正确版本的方法是使用Maven进行依赖项解析。你能克隆并执行,看看是否有效吗?我已经用jar文件更新了这个问题,请检查一下…酷。想在没有Maven的情况下写一篇关于如何设置的博客吗?可能对其他人有用。@Ramesh K既然spring-data-neo4j 2.1.0还不存在,您是如何下载它的?仅2.1.0.BUILD-SNPASHOTexists@Mik378@Ramesh K:)谢谢!