2

SDN 4.1.0.RC1を使用するようにアプリケーションを移行中ですが、アプリケーションの起動後に問題が発生しました。私はリモートサーバ(localhost:7474)にHTTPDriverを正しく使用するために必要な設定を変更しました。アプリケーションを起動すると、スプリングコンテキストを読み込もうとしているときに私のリポジトリに次のエラーが表示されます。SDN 4.0からSDN 4.1.RC1への移行時にGraphQueryLookupStrategy.resolveQuery例外が発生しました

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userRepository': Invocation of init method failed; nested exception is java.lang.AbstractMethodError: org.springframework.data.neo4j.repository.query.GraphQueryLookupStrategy.resolveQuery(Ljava/lang/reflect/Method;Lorg/springframework/data/repository/core/RepositoryMetadata;Lorg/springframework/data/repository/core/NamedQueries;)Lorg/springframework/data/repository/query/RepositoryQuery; 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1578) 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:545) 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482) 
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) 
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) 
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) 
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) 
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:1192) 
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1116) 
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1014) 
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:545) 
    ... 32 common frames omitted 
Caused by: java.lang.AbstractMethodError: org.springframework.data.neo4j.repository.query.GraphQueryLookupStrategy.resolveQuery(Ljava/lang/reflect/Method;Lorg/springframework/data/repository/core/RepositoryMetadata;Lorg/springframework/data/repository/core/NamedQueries;)Lorg/springframework/data/repository/query/RepositoryQuery; 
    at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.<init>(RepositoryFactorySupport.java:416) 
    at org.springframework.data.repository.core.support.RepositoryFactorySupport.getRepository(RepositoryFactorySupport.java:206) 
    at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.initAndReturn(RepositoryFactoryBeanSupport.java:251) 
    at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.afterPropertiesSet(RepositoryFactoryBeanSupport.java:237) 
    at org.springframework.data.neo4j.repository.support.GraphRepositoryFactoryBean.afterPropertiesSet(GraphRepositoryFactoryBean.java:43) 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1637) 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1574) 
    ... 42 common frames omitted 

これは、春データと春のデータのNeo4jのバージョンの間で切断することができように見えます

@Repository 
public interface UserRepository extends GraphRepository<User> { 

    @Query("MATCH (u:User) where u.authId = {authId} return u limit 1") 
    User findOneByAuthId(@Param("authId") Long authId); 

} 

EDIT

を泣いているように見えるvaniliaリポジトリです。

問題のGraphQueryLookupStrategy ...

/* 
* Copyright (c) [2011-2016] "Pivotal Software, Inc."/"Neo Technology"/"Graph Aware Ltd." 
* 
* This product is licensed to you under the Apache License, Version 2.0 (the "License"). 
* You may not use this product except in compliance with the License. 
* 
* This product may include a number of subcomponents with 
* separate copyright notices and license terms. Your use of the source 
* code for these subcomponents is subject to the terms and 
* conditions of the subcomponent's license, as noted in the LICENSE file. 
* 
*/ 

package org.springframework.data.neo4j.repository.query; 

import org.neo4j.ogm.session.Session; 
import org.springframework.data.projection.ProjectionFactory; 
import org.springframework.data.repository.core.NamedQueries; 
import org.springframework.data.repository.core.RepositoryMetadata; 
import org.springframework.data.repository.query.QueryLookupStrategy; 
import org.springframework.data.repository.query.RepositoryQuery; 

import java.lang.reflect.Method; 

/** 
* @author Mark Angrish 
* @author Luanne Misquitta 
* @author Oliver Gierke 
*/ 
public class GraphQueryLookupStrategy implements QueryLookupStrategy { 

    private final Session session; 

    public GraphQueryLookupStrategy(Session session) { 
     this.session = session; 
    } 

    /* 
    * (non-Javadoc) 
    * @see org.springframework.data.repository.query.QueryLookupStrategy#resolveQuery(java.lang.reflect.Method, org.springframework.data.repository.core.RepositoryMetadata, org.springframework.data.projection.ProjectionFactory, org.springframework.data.repository.core.NamedQueries) 
    */ 
    @Override 
    public RepositoryQuery resolveQuery(Method method, RepositoryMetadata metadata, ProjectionFactory factory, 
     NamedQueries namedQueries) { 
     return new GraphQueryMethod(method, metadata, factory, session).createQuery(); 
    } 
} 

私ははっきりとそれがされていない実装する方法RepositoryQuery resolveQuery(Method method, RepositoryMetadata metadata, NamedQueries namedQueries);を期待しているQueryLookupStrategyを表示されます。私はこれが今、依存関係の問題であると私は

/* 
* Copyright 2008-2010 the original author or authors. 
* 
* Licensed under the Apache License, Version 2.0 (the "License"); 
* you may not use this file except in compliance with the License. 
* You may obtain a copy of the License at 
* 
*  http://www.apache.org/licenses/LICENSE-2.0 
* 
* Unless required by applicable law or agreed to in writing, software 
* distributed under the License is distributed on an "AS IS" BASIS, 
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
* See the License for the specific language governing permissions and 
* limitations under the License. 
*/ 
package org.springframework.data.repository.query; 

import java.lang.reflect.Method; 
import java.util.Locale; 

import org.springframework.data.repository.core.NamedQueries; 
import org.springframework.data.repository.core.RepositoryMetadata; 
import org.springframework.util.StringUtils; 

/** 
* Strategy interface for which way to lookup {@link RepositoryQuery}s. 
* 
* @author Oliver Gierke 
*/ 
public interface QueryLookupStrategy { 

    public static enum Key { 

     CREATE, USE_DECLARED_QUERY, CREATE_IF_NOT_FOUND; 

     /** 
     * Returns a strategy key from the given XML value. 
     * 
     * @param xml 
     * @return a strategy key from the given XML value 
     */ 
     public static Key create(String xml) { 

      if (!StringUtils.hasText(xml)) { 
       return null; 
      } 

      return valueOf(xml.toUpperCase(Locale.US).replace("-", "_")); 
     } 
    } 

    /** 
    * Resolves a {@link RepositoryQuery} from the given {@link QueryMethod} that can be executed afterwards. 
    * 
    * @param method 
    * @param metadata 
    * @param namedQueries 
    * @return 
    */ 
    RepositoryQuery resolveQuery(Method method, RepositoryMetadata metadata, NamedQueries namedQueries); 
} 

答えて

6

オーケーSDNに準拠する必要が春データのバージョンをさらに調査すると仮定し、あなたがこの問題に実行する場合、解決するために、かなりまっすぐ進む方法がありますそれ。 http://projects.spring.io/spring-data/のドキュメントを参照してください。この例外は、スプリングデータコモンズモジュールとのバージョンの競合によって発生しました。バージョン4.1.0.RC1でneo4jが実装するインタフェースが変更され、この例外がスローされます。

解決するには、Spring DataリリーストレインBOMを使用し、Hopper-RC1をリリースするように設定します。私はgradleを使っているので、指示は以下の通りですが、あなたは上のリンクでそれらを見つけることもできます。

関連ビルドスクリプト簡素化...

buildscript { 
    dependencies { 
    classpath "io.spring.gradle:dependency-management-plugin:0.4.0.RELEASE" 
    } 
} 

apply plugin: "io.spring.dependency-management" 

dependencyManagement { 
    imports { 
    mavenBom 'org.springframework.data:spring-data-releasetrain:Hopper-RC1' 
    } 
} 

dependencies { 
    compile 'org.springframework.data:spring-data-neo4j:4.1.0.RC1' 
}repositories { 
    maven { 
     url 'https://repo.spring.io/libs-milestone' 
    } 
} 

乾杯、MavenのユーザーのためのHolycowzerの答え@上の拡大

スティーブ

+0

は完全に機能します。ありがとう@Holycowzer! – Lina

+0

これは機能しました。今はHopper-RELEASEを使うことができますが、これはまだ動作します。 –

2

。ビルドPOM.xmlに次の行を追加します。これは、メインの<dependencies />タグセットの外側にあります。

<dependencyManagement> 
    <dependencies> 
    <dependency> 
     <groupId>org.springframework.data</groupId> 
     <artifactId>spring-data-releasetrain</artifactId> 
     <version>Hopper-SR1</version> 
     <type>pom</type> 
     <scope>import</scope> 
    </dependency> 
    </dependencies> 
</dependencyManagement> 

は、私はいくつかの輸入がこれをやっている間、単にあなたのPOMで依存関係として明示的にそれらを追加破っ気づき、すべてが期待どおりに動作するはずです。

関連する問題