MapStruct for automated DTO to Entity mapping and vice versa

This code example demonstrates the use of MapStruct when we need to convert basic objects into DTOs.

We start by adding the MapStruct dependencies to a Spring project. Here we use a new project, but the procedure is the same for mature projects as well.

pom.xml
<dependencies>
<dependency>
<groupId>org.mapstruct</groupId>