September 2019
Intermediate to advanced
668 pages
15h 59m
English
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. ...