-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 

나는 모든 확인을 작동 CustomizedARepoImplcom.app.domain.repo로 이동합니다.

+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입니다. 봄에서 온 사람들이 왜 이렇게했는지 확인합니다 ...