2015-02-04 2 views
14

나는 spring-data-rest를 사용하는 프로젝트를 가지고 있으며 Spring 데이터만을 사용하는 의존성 프로젝트를 가지고있다. 두 프로젝트 모두 스프링 데이터 저장소가 있으며 저장소 인터페이스를 구현하는 데 @EnableJpaRepositories을 사용하지만 부모 프로젝트에만 저장소를 내보내려고합니다.스프링 데이터 REST 리포지토리의 기본 노출을 비활성화하는 방법은 무엇입니까?

여기 내 질문 : @RepositoryRestResource(exported = false) 종속 프로젝트의 모든 저장소에 명시 적으로 주석을 추가하지 않고도 부모 프로젝트의 리소스에 대한 나머지 끝점 만 노출하도록 Spring Data REST를 구성하는 방법이 있습니까?

@RepositoryRestResource을 사용 중지하면이 작업을 수행 할 수 있고 다른 유스 케이스의 다른 프로젝트는 해당 저장소에 대해 REST 엔드 포인트를 사용할 수 없으므로 종속 프로젝트는 스프링 데이터 REST 만 포함해야합니다 for ...

답변

13

현재 찾고있는 것에 대한 글로벌 스위치가 없습니다. 다음 주요 배포에 포함시키기 위해 this ticket을 제출했습니다.

옵션이 맞는지 확실하지 않지만 패키지 개인 저장소 인터페이스는 명시 적으로 주석이 첨부되어 있지 않으면 노출되지 않습니다. 모든 라이브러리 저장소를 보호 할 수 있다면 명시 적 주석보다 유리할 수 있습니다.

+2

의 repos 패키지 - 개인 제작. 그 티켓을 만들어 줘서 고마워. – gyoder

12

이 특정 설정을 찾고있을 때 여기를 반복합니다. 이제 구현 된 것 같습니다. 이 경우, 기본 노출을 피하기 위해 spring.data.rest.detection-strategy = annotated을 설정하고자 할 것입니다.

모든 application.properties 옵션 :

# Exposes all public repository interfaces but considers @(Repository)RestResource\u2019s `exported flag. 
spring.data.rest.detection-strategy=default 

# Exposes all repositories independently of type visibility and annotations. 
spring.data.rest.detection-strategy=all 

# Only repositories annotated with @(Repository)RestResource are exposed, unless their exported flag is set to false. 
spring.data.rest.detection-strategy=annotated 

# Only public repositories annotated are exposed. 
spring.data.rest.detection-strategy=visibility 

참조 : 4.6.1. Which repositories get exposed by defaults?

관련 문제