Skip to Content
Hands-On Microservices with Spring Boot and Spring Cloud
book

Hands-On Microservices with Spring Boot and Spring Cloud

by Magnus Larsson
September 2019
Intermediate to advanced
668 pages
15h 59m
English
Packt Publishing
Content preview from Hands-On Microservices with Spring Boot and Spring Cloud

The use of the persistence layer

The source code in the service layer for using the persistence layer is structured in the same way for all core microservices. Therefore, we will only go through the source code for the Product microservice.

First, we need to inject the repository class from the persistence layer and a Java bean mapper class into the constructor:

private final ServiceUtil serviceUtil;private final ProductRepository repository;private final ProductMapper mapper;@Autowiredpublic ProductServiceImpl(ProductRepository repository, ProductMapper mapper, ServiceUtil serviceUtil) {    this.repository = repository;    this.mapper = mapper;    this.serviceUtil = serviceUtil;}

In the next section, we will see how the Java mapper class is defined. ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Master Microservices with Spring Boot and Spring Cloud

Master Microservices with Spring Boot and Spring Cloud

In28Minutes Official

Publisher Resources

ISBN: 9781789613476Supplemental Content