在 Spring Data Neo4j 4.1-SNAPSHOT 中检索 @QueryResult 时出现 NoSuchMethodError

NoSuchMethodError when retrieving a @QueryResult in Spring Data Neo4j 4.1-SNAPSHOT

我最近升级到 Spring-Data-Neo4j 4.1.0-BUILD-SNAPSHOT(使用 neo4j-ogm 2.0.0-M01)并注意到检索 @QueryResult 的查询不再有效.我收到以下错误:

java.lang.NoSuchMethodError: org.neo4j.ogm.response.model.DefaultRestModel.<init>(Ljava/util/Map;)V
at org.neo4j.ogm.drivers.http.response.RestModelResponse.next(RestModelResponse.java:39)
at org.neo4j.ogm.drivers.http.response.RestModelResponse.next(RestModelResponse.java:28)
at org.neo4j.ogm.context.RestModelMapper.map(RestModelMapper.java:53)
at org.neo4j.ogm.session.delegates.ExecuteQueriesDelegate.query(ExecuteQueriesDelegate.java:97)
at org.neo4j.ogm.session.delegates.ExecuteQueriesDelegate.query(ExecuteQueriesDelegate.java:76)
at org.neo4j.ogm.session.Neo4jSession.query(Neo4jSession.java:313)
at org.springframework.data.neo4j.repository.query.QueryResultGraphRepositoryQuery.apply(QueryResultGraphRepositoryQuery.java:69)
at org.springframework.data.neo4j.repository.query.QueryResultGraphRepositoryQuery.apply(QueryResultGraphRepositoryQuery.java:64)
at org.neo4j.ogm.session.delegates.TransactionsDelegate.doInTransaction(TransactionsDelegate.java:46)
at org.neo4j.ogm.session.Neo4jSession.doInTransaction(Neo4jSession.java:386)
at org.springframework.data.neo4j.repository.query.QueryResultGraphRepositoryQuery.mapToConcreteType(QueryResultGraphRepositoryQuery.java:64)
at org.springframework.data.neo4j.repository.query.QueryResultGraphRepositoryQuery.execute(QueryResultGraphRepositoryQuery.java:52)
at org.springframework.data.neo4j.repository.query.GraphRepositoryQuery.execute(GraphRepositoryQuery.java:52)
at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.doInvoke(RepositoryFactorySupport.java:482)
at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:460)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.transaction.interceptor.TransactionInterceptor.proceedWithInvocation(TransactionInterceptor.java:99)
at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:281)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:136)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207)
at com.sun.proxy.$Proxy49.getParticipatingMolecules2(Unknown Source)
at uk.ac.ebi.reactome.service.DatabaseObjectServiceImpl.getParticipatingMolecules2(DatabaseObjectServiceImpl.java:59)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
at org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint.proceed(MethodInvocationProceedingJoinPoint.java:85)
at uk.ac.ebi.reactome.aop.LoggingAspect.monitorExecutionTimes(LoggingAspect.java:37)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:621)
at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:610)
at org.springframework.aop.aspectj.AspectJAroundAdvice.invoke(AspectJAroundAdvice.java:68)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.transaction.interceptor.TransactionInterceptor.proceedWithInvocation(TransactionInterceptor.java:99)
at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:281)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207)
at com.sun.proxy.$Proxy51.getParticipatingMolecules2(Unknown Source)
at uk.ac.ebi.reactome.service.DatabaseObjectServiceTest.testGetParticipatingMolecules2(DatabaseObjectServiceTest.java:144)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at org.junit.runners.model.FrameworkMethod.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:75)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:86)
at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:84)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:254)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:89)
at org.junit.runners.ParentRunner.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access[=11=]0(ParentRunner.java:58)
at org.junit.runners.ParentRunner.evaluate(ParentRunner.java:268)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:193)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:78)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:212)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:68)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:140)

@QueryResult 对象:

 @QueryResult
 public class Participant {
    private Long ewasDbId;
    private String ewasName;
    private Collection<Long> refEntityDbIds;
    private Collection<String> refEntityNames;
}

查询:

 @Query("MATCH (n:Pathway{dbId:{0}})-[:hasEvent|input|output*]->(m)-[:hasMember|hasComponent|hasCandidate|repeatedUnit|referenceEntity*]->(x:ReferenceEntity) RETURN m.dbId AS ewasDbId, m.displayName AS ewasName, COLLECT(DISTINCT x.dbId) AS refEntityDbIds, COLLECT(DISTINCT x.displayName) AS refEntityNames") 
 Collection<Participant> getParticipatingMolecules2(Long dbId); 

依赖关系:

<!--Spring data neo4j-->
<dependency>
    <groupId>org.springframework.data</groupId>
    <artifactId>spring-data-neo4j</artifactId>
    <version>4.1.0.BUILD-SNAPSHOT</version>
</dependency>
<!--Neo4j object graph mapping -->
<dependency>
    <groupId>org.neo4j</groupId>
    <artifactId>neo4j-ogm-api</artifactId>
    <version>2.0.0-M01</version>
</dependency>
<dependency>
    <groupId>org.neo4j</groupId>
    <artifactId>neo4j-ogm-core</artifactId>
    <version>2.0.0-M01</version>
</dependency>
... 

依赖树

[INFO] +- org.reactome.base:reactome-base:jar:1.2.1:compile
[INFO] |  \- mysql:mysql-connector-java:jar:5.1.28:compile
[INFO] +- org.springframework.data:spring-data-neo4j:jar:4.1.0.BUILD-SNAPSHOT:compile
[INFO] |  +- org.springframework.data:spring-data-commons:jar:1.12.0.BUILD-SNAPSHOT:compile
[INFO] |  |  \- org.springframework:spring-beans:jar:4.1.9.RELEASE:compile
[INFO] |  +- org.springframework:spring-context:jar:4.1.9.RELEASE:compile
[INFO] |  |  +- org.springframework:spring-aop:jar:4.1.9.RELEASE:compile
[INFO] |  |  |  \- aopalliance:aopalliance:jar:1.0:compile
[INFO] |  |  \- org.springframework:spring-expression:jar:4.1.9.RELEASE:compile
[INFO] |  +- org.springframework:spring-tx:jar:4.1.9.RELEASE:compile
[INFO] |  +- org.slf4j:slf4j-api:jar:1.7.13:compile
[INFO] |  \- org.slf4j:jcl-over-slf4j:jar:1.7.13:runtime
[INFO] +- org.springframework:spring-test:jar:4.2.4.RELEASE:test
[INFO] |  \- org.springframework:spring-core:jar:4.2.4.RELEASE:compile
[INFO] |     \- commons-logging:commons-logging:jar:1.2:compile
[INFO] +- org.neo4j:neo4j-ogm-api:jar:2.0.0-M01:compile
[INFO] |  +- com.fasterxml.jackson.core:jackson-databind:jar:2.5.1:compile
[INFO] |  |  +- com.fasterxml.jackson.core:jackson-annotations:jar:2.5.0:compile
[INFO] |  |  \- com.fasterxml.jackson.core:jackson-core:jar:2.5.1:compile
[INFO] |  +- ch.qos.logback:logback-classic:jar:1.1.3:compile
[INFO] |  +- ch.qos.logback:logback-core:jar:1.1.3:compile
[INFO] |  \- commons-codec:commons-codec:jar:1.10:compile
[INFO] +- org.neo4j:neo4j-ogm-core:jar:2.0.0-M01:compile
[INFO] |  +- org.neo4j:neo4j-ogm-compiler:jar:2.0.0-SNAPSHOT:compile
[INFO] |  +- org.neo4j:neo4j-ogm-drivers:jar:2.0.0-SNAPSHOT:compile
[INFO] |  |  +- org.neo4j:neo4j:jar:2.3.2:compile
[INFO] |  |  |  +- org.neo4j:neo4j-kernel:jar:2.3.2:compile
[INFO] |  |  |  |  +- org.neo4j:neo4j-primitive-collections:jar:2.3.2:compile
[INFO] |  |  |  |  |  +- org.neo4j:neo4j-unsafe:jar:2.3.2:compile
[INFO] |  |  |  |  |  \- org.neo4j:neo4j-function:jar:2.3.2:compile
[INFO] |  |  |  |  +- org.neo4j:neo4j-io:jar:2.3.2:compile
[INFO] |  |  |  |  |  \- org.apache.commons:commons-lang3:jar:3.3.2:compile
[INFO] |  |  |  |  +- org.neo4j:neo4j-csv:jar:2.3.2:compile
[INFO] |  |  |  |  \- org.neo4j:neo4j-logging:jar:2.3.2:compile
[INFO] |  |  |  +- org.neo4j:neo4j-lucene-index:jar:2.3.2:compile
[INFO] |  |  |  |  \- org.apache.lucene:lucene-core:jar:3.6.2:compile
[INFO] |  |  |  +- org.neo4j:neo4j-graph-algo:jar:2.3.2:compile
[INFO] |  |  |  +- org.neo4j:neo4j-udc:jar:2.3.2:compile
[INFO] |  |  |  +- org.neo4j:neo4j-graph-matching:jar:2.3.2:compile
[INFO] |  |  |  +- org.neo4j:neo4j-cypher:jar:2.3.2:compile
[INFO] |  |  |  |  +- org.scala-lang:scala-library:jar:2.11.7:compile
[INFO] |  |  |  |  +- org.scala-lang:scala-reflect:jar:2.11.7:compile
[INFO] |  |  |  |  +- org.scala-lang.modules:scala-parser-combinators_2.11:jar:1.0.4:compile
[INFO] |  |  |  |  +- org.neo4j:neo4j-codegen:jar:2.3.2:compile
[INFO] |  |  |  |  |  \- org.ow2.asm:asm:jar:5.0.2:compile
[INFO] |  |  |  |  +- org.neo4j:neo4j-cypher-compiler-1.9_2.11:jar:2.0.5:compile
[INFO] |  |  |  |  +- org.neo4j:neo4j-cypher-compiler-2.2_2.11:jar:2.2.6:compile
[INFO] |  |  |  |  +- org.neo4j:neo4j-cypher-compiler-2.3:jar:2.3.2:compile
[INFO] |  |  |  |  |  \- org.neo4j:neo4j-cypher-frontend-2.3:jar:2.3.2:compile
[INFO] |  |  |  |  +- org.parboiled:parboiled-scala_2.11:jar:1.1.7:compile
[INFO] |  |  |  |  |  \- org.parboiled:parboiled-core:jar:1.1.7:compile
[INFO] |  |  |  |  +- net.sf.opencsv:opencsv:jar:2.3:compile
[INFO] |  |  |  |  \- com.googlecode.concurrentlinkedhashmap:concurrentlinkedhashmap-lru:jar:1.4.2:compile
[INFO] |  |  |  +- org.neo4j:neo4j-jmx:jar:2.3.2:compile
[INFO] |  |  |  \- org.neo4j:neo4j-consistency-check:jar:2.3.2:compile
[INFO] |  |  |     \- org.neo4j:neo4j-consistency-check-legacy:jar:2.3.2:compile
[INFO] |  |  +- org.neo4j.driver:neo4j-java-driver:jar:1.0.0-M01:compile
[INFO] |  |  +- org.apache.httpcomponents:httpclient:jar:4.3.6:compile
[INFO] |  |  |  \- org.apache.httpcomponents:httpcore:jar:4.3.3:compile
[INFO] |  |  \- commons-io:commons-io:jar:2.4:compile
[INFO] |  \- commons-lang:commons-lang:jar:2.6:compile
[INFO] +- org.aspectj:aspectjweaver:jar:1.8.8:compile
[INFO] +- junit:junit:jar:4.12:test 
[INFO] |  \- org.hamcrest:hamcrest-core:jar:1.3:test
[INFO] \- com.martiansoftware:jsap:jar:2.1:compile

我是不是做错了什么,或者这个问题会在未来得到解决吗?

感谢您的帮助

不确定这是怎么发生的,但看起来它需要 neo4j-ogm 2.0.0-SNAPSHOT 你可以做一个 mvn clean -U ... 看看它是否解决了问题,或者使用 neo4j-ogm 快照?您需要包括

  <repository>
      <id>neo4j-snapshots</id>
      <url>http://m2.neo4j.org/content/repositories/snapshots</url>
      <snapshots>
      <enabled>true</enabled>
      </snapshots>
  </repository>

更新

您的依赖关系树包括混合版本

+- org.neo4j:neo4j-ogm-core:jar:2.0.0-M01:compile
[INFO] |  +- org.neo4j:neo4j-ogm-compiler:jar:2.0.0-SNAPSHOT:compile
[INFO] |  +- org.neo4j:neo4j-ogm-drivers:jar:2.0.0-SNAPSHOT:compile

它应该有 2.0.0-M01 或 2.0.0-SNAPSHOT 但不能同时有,因为它们在 QueryResult 方面不兼容。 也许从本地 Maven 存储库 (org/neo4j/neo4j-ogm) 中删除 2.0.0-M01 和 2.0.0-SNAPSHOT 并使用 mvn -U ?

强制更新