// Spring Data REST - 스프링 데이터 레포지토리를 자동으로 RESTful 웹 서비스로 노출
implementation 'org.springframework.boot:spring-boot-starter-data-rest'
// REST API를 탐색하고, 테스트 할 수 있는 웹 기반 인터페이스를 제공
implementation 'org.springframework.data:spring-data-rest-hal-explorer'
// yaml
data:
rest:
detection-strategy: annotated
base-path: /api
// properties
data.rest.detection-strategy=annotated
data.rest.base-path=/api
detection-strategy = annotated
: @RepositoryRestResource
어노테이션이 붙은 Repository만 REST 리소스로 노출시켜준다.
@RepositoryRestResource
public interface ArticleRepository extends JpaRepository<Article, Long> {
}
위에 설정해두었던 대로, REST 리소스를 노출할 레포지토리에 @RepositoryRestResource
를 달아준다.
브라우저에 base-path를 지정해 준 경로대로 입력한다.
ex ) http://localhost:8080/api
컨트롤러를 아직 만들지 않았음에도 불구하고
HTTP Request 아래의 버튼들을 눌러
GET, POST 등을 편리하게 사용 할 수 있다.
잘 보고 갑니다~