我一直在尝试让这个简单的例子运行(java 1.7) https://github.com/spring-guides/gs-accessing-neo4j-data-rest/tree/master/complete
当尝试通过application类中的main方法启动应用程序时,我一直得到以下错误:
我把整个日志上传到这个要点:http://bit.ly/1hU7Vpu
下面是错误总结。
WARN 6470 --- [ main] o.s.boot.SpringApplication : Error handling failed (Error creating bean with name 'org.springframework.data.rest.webmvc.config.RepositoryRestMvcConfiguration': Initialization of bean failed; nested exception is java.lang.NoSuchMethodError: org.springframework.data.rest.webmvc.config.RepositoryRestMvcConfiguration.setBeanFactory(Lorg/springframework/beans/factory/BeanFactory;)V)
Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityFetchHandler' defined in class hello.Application: Instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: Factory method [public org.springframework.data.neo4j.support.mapping.Neo4jEntityFetchHandler org.springframework.data.neo4j.config.Neo4jConfiguration.entityFetchHandler() throws java.lang.Exception] threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'nodeStateTransmitter' defined in class hello.Application: Initialization of bean failed; nested exception is java.lang.reflect.MalformedParameterizedTypeException
我认为您看到的是Spring版本冲突。请参阅错误日志中的以下行:
exception is java.lang.NoSuchMethodError: org.springframework.data.rest.webmvc.config.RepositoryRestMvcConfiguration.setBeanFactory(Lorg/springframework/beans/factory/BeanFactory;)V)
您应该能够通过删除以下行(无论如何您可能不需要它)来防止此错误:
@Import(RepositoryRestMvcConfiguration.class)
可以显示mvn dependency:tree
的输出吗?在你的类路径中可能有重复的Spring库。
似乎是SDN的快照发布导致了这个问题。使用
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-neo4j</artifactId>
<version>3.0.1.RELEASE</version>
</dependency>
不是<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-neo4j</artifactId>
<version>3.1.0.BUILD-SNAPSHOT</version>
</dependency>
你可能发现了一个bug!