February 2018
Intermediate to advanced
406 pages
9h 55m
English
The annotations in Spring Boot make it easy to extract parameters and path variables and execute the service. For now, let's mock the response instead of getting the data from the database.
Create a simple Java entity called the Product class. For now, it is a simple Plain Old Java Object (POJO) class with three fields:
publicclass Product { privateint id = 1 ; private String name = "Oranges " ; privateint catId = 2 ;
Add the getter and setter methods and a constructor that accepts the product ID:
public Product(int id) { this.id = id; }
Also, add an empty constructor that will be used by the service client, as we will see later:
public Product() { }
Then, write the ProductService class as follows:
Read now
Unlock full access