카테고리 없음

BasePathAwareController

gu9gu 2024. 1. 11. 15:59

BasePathAwareController 사용 이유

@RepositoryRestResource를 사용해서 spring data rest api 만들었을 때 api 경로를 확장하기 위해 사용

https://faithfull.me/overriding-spring-data-rest-repositories

 

 

사용 시 주의사항

사용할 때 헨들링 하는 타입을 Resources, HttpEntity , ResponseEntity 같은 타입으로 지정

 

 

 

※ spring docs 확인하고 spring 프로젝트에서 소스들도 직접 확인해서 사용 방법을 살펴보면 좋다.

spring docs

https://docs.spring.io/spring-data/rest/docs/current/api/org/springframework/data/rest/webmvc/BasePathAwareController.html

 

spring data rest 소스

https://github.com/spring-projects/spring-data-rest 프로젝트에서 BasePathAwareController 검색. - > 

 - ProfileController .java, RepositorySchemaController.java에서 사용 예시 확인

https://github.com/spring-projects/spring-data-rest/blob/main/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/RepositorySchemaController.java