-1

スプリング・データ・リポジトリの実装を別のフォルダに移動することはできますか(オリジナル・インターフェースと同じかサブフォルダではない)?私は同じフォルダ内のインターフェイスと実装を持っている場合、すべて正常に動作します。たとえばcom.app.domain.repoからcom.app.infrastr.repoに移動すると、私はInvocation of init method failed; nested exception is org.springframework.data.mapping.PropertyReferenceException: No property methodName found for type RepoInterfaceNameとなります。スプリング・リポジトリを別のフォルダに移動

UPDATE

import com.app.domain.repo 

public interface ARepo extends ElasticsearchRepository<A, String>, CustomizedARepo { 
} 

public interface CustomizedARepo { 
    List<A> makeSearch(int x); 
} 

import com.app.infrastr.repo 

public class CustomizedARepoImpl implements CustomizedARepo { 

    private ElasticsearchTemplate elasticsearchTemplate; 

    public CustomizedARepoImpl(ElasticsearchTemplate elasticsearchTemplate) { 
     this.elasticsearchTemplate = elasticsearchTemplate; 
    } 

    @Override 
    public List<A> makeSearch(int x){ return null; } 
} 

と構成のクラス

@Configuration 
@EnableElasticsearchRepositories(basePackages = {"com.app.domain.repo", "com.app.infrastr.repo"}) 
public class Config{} 

エラーがあるさ:

Invocation of init method failed; nested exception is org.springframework.data.mapping.PropertyReferenceException: No property makeSearch found for type ARepo 

私はcom.app.domain.repoCustomizedARepoImplを移動した場合、すべてがOKに動作します。

+0

ここで関連するコードを入力して回答してください。ここには多くの可能性があります。私の推測では、特定のパッケージを指すカスタムのentityManagerFactory()Beanがあることです。 – Brian

+0

私は質問を更新しました。 – bojanv55

+0

あなたが追加した内容に基づいて、JPAとESのリポジトリを混在させるかどうかは疑問です。この回答は役に立ちますか? https://stackoverflow.com/a/32879779/4614870 – Brian

答えて

0

理由が見つかりました。それは私が

public Iterable<String> getBasePackages() { 
      return configuration.getBasePackages(); 
     } 

すべて期待どおりに動作にこれを変更する場合は、この

public Iterable<String> getBasePackages() { 
      return Collections.singleton(ClassUtils.getPackageName(fragmentInterfaceName)); 
     } 

のように同じフォルダ内に実装しています春・データ・コモンズでファイルRepositoryBeanDefinitionBuilder内部方法getBasePackagesです。なぜ春からの人たちがこのようにしたのかをチェックします...

関連する問題