Controller Interface 이용하기 Posted on 2021-06-04 | In Spring | 아래와 같이 설정해준 다음 1234567891011121314 @RequestMapping("/default") public interface Test { @GetMapping("/") List<TestDto> getAll(); @GetMapping("/{id}") Optional<TestDto> getById(@PathVariable int id); @PostMapping("/save/{id}") void save(@RequestBody TestDto testDto, @PathVariable int id); } 1234567891011121314151617181920212223@RestController @RequestMapping("/test") @RequiredArgsConstructor public class TestController implements Test { private final TestService testService; @Override public List<TestDto> getAll() { this.testService.getAll(); } @Override public Optional<TestDto> getById(int id) { this.testService.getById(id); } @Override public void save(TestDto testDto, int id) { this.testService.save(testDto, id); } } 테스트 전송 ```http request curl http://localhost:8080/test/ GET http://localhost:8080/test/ ### ```