简体   繁体   中英

Spring Data Rest and Rest Controller together

I'm using Spring Data Rest and have @RepositoryRestResource defined with the path is "pathXYZ" . Now I have a class with @RestController and defined a @GetMapping with "pathXYZ/custom" .

It seems "pathXYZ/custom" is not able to serve.

If I changed "pathXYZ/custom" to "pathABC/custom" , it is working as normal.

Is that the way to have @RestController and @RespositoryRestResource working on the same 'base' context path?

What you need is to annotate your MVC Controller with @RepositoryRestController instead of @RestController

https://docs.spring.io/spring-data/rest/docs/current/reference/html/#customizing-sdr.overriding-sdr-response-handlers

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM