Home > database >  Spring Interface Driven Controllers usage
Spring Interface Driven Controllers usage

Time:09-29

I used to write @RestControllers without interface, but suddenly saw article https://www.baeldung.com/spring-interface-driven-controllers, describing such pattern Interface Driven Controllers. So the question is: why its need to create controllers with special interface per controller with annotated methods, for example @GetMapping, @RequestBody, @PathVariable etc. at all? It seems more complicated without any profit for me.

CodePudding user response:

In article is perfectly explained you can implement one interface with same methods in two controllers:

@RequestMapping("/oldversioncontroller/book")
public class BookOldController implements BookOperations {...}

@RequestMapping("/newversioncontroller/book")
public class BookNewController implements BookOperations {...}
  • Related