Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Rest API with Spring Boot

Rest API with Spring Boot

Building REST API with Spring Boot, Kotlin, FlywayDB, PostgreSQL and Test with JUnit and Mockito. Case study Shopping Cart API.

KMKLabs

June 12, 2018
Tweet

More Decks by KMKLabs

Other Decks in Programming

Transcript

  1. About Spring Boot •Simplicity and speed of development improvement •Convention

    over configuration / Automatic configure •Dependencies management without name and versions (spring-boot-starter-*) •No XML configuration •Embedded Tomcat or Jetty (Stand-alone Apps) •Support Maven & Gradle
  2. Annotation/Configuration Name Description @SpringBootApplication Entry point of spring boot config

    to use auto-configuration, component scan and be able to define extra configuration on their "application class" @Configuration Mark class as config class @EnableJpaAuditing Transparently keep track of who created or changed an entity and the point in time this happened @Repository Mark the specific class as a Data Access Object, persistence layer @Autowired Tells DI container for dependency injection @Service Service layer @Controller Presentation layer @RestController Presentation layer for REST @ControllerAdvice Apply globally to all Controllers @ExceptionHandler Annotation for handling exceptions in specific handler classes and/or handler methods.
  3. Configuration Name Description @RequestMapping Mapping an HTTP request to a

    method using some basic criteria @RequestParam obtain an parameter from the URI / form @RequestBody @Valid Body of the web request, validate & deserialized to object @Transactional Handling transaction @PathVariable Annotation which indicates that a method parameter should be bound to a URI template variable And many more, please check Spring documentation