REST controller

The REST controller defines URI paths that the service is going to respond to. It declares paths and corresponding HTTP methods that each controller method should react to. We define all of these using annotations. This approach is very similar to JAX-RS with Jersey. Our service has just one, single book resource, so we will have just a single controller for starters. It will be BookController class, defined in the BookController.java:

package pl.finsys.example.controller; import org.springframework.beans.factory.annotation.Autowired; import pl.finsys.example.domain.Book; import pl.finsys.example.service.BookService; import pl.finsys.example.service.exception.BookAlreadyExistsException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; ...

Get Docker and Kubernetes for Java Developers now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.