I'm using the latest versions of Spring boot above 2.2.5 and Java 15, lombok, Mapstruct for mapping some pojos.
When using version 2.2.5 of spring boot I'm getting the expected result :
@Generated(
value = "org.mapstruct.ap.MappingProcessor",
date = "2021-01-02T21:59:24+0100",
comments = "version: 1.4.1.Final, compiler: javac, environment: Java 15.0.1 (Oracle Corporation)"
)
@Component
public class ProduitMapperImpl implements ProduitMapper {
@Override
public ProduitDtoResponse produitToProduitDtoResponse(Produit produit) {
if ( produit == null ) {
return null;
}
ProduitDtoResponseBuilder produitDtoResponse = ProduitDtoResponse.builder();
produitDtoResponse.id( produit.getId() );
produitDtoResponse.nom( produit.getNom() );
produitDtoResponse.prix( produit.getPrix() );
return produitDtoResponse.build();
}
@Override
public Produit produitToProduitDtoResponse(ProduitDtoResponse produitDto) {
if ( produitDto == null ) {
return null;
}
ProduitBuilder produit = Produit.builder();
produit.id( produitDto.getId() );
produit.nom( produitDto.getNom() );
produit.prix( produitDto.getPrix() );
return produit.build();
}
}
But when using Version 2.4 and above, there's no builder, instead I have the java new keyword and not the other fields, I'm getting :
Here's the maven pom conf that's not working : BOM
@Generated(
value = "org.mapstruct.ap.MappingProcessor",
date = "2021-01-02T22:05:16+0100",
comments = "version: 1.4.1.Final, compiler: javac, environment: Java 15.0.1 (Oracle Corporation)"
)
@Component
public class ProduitMapperImpl implements ProduitMapper {
@Override
public ProduitDtoResponse produitToProduitDtoResponse(Produit produit) {
if ( produit == null ) {
return null;
}
ProduitDtoResponse produitDtoResponse = new ProduitDtoResponse();
return produitDtoResponse;
}
@Override
public Produit produitToProduitDtoResponse(ProduitDtoResponse produitDto) {
if ( produitDto == null ) {
return null;
}
Produit produit = new Produit();
return produit;
}
}
The only thing I change is Spring Boot version and it work as expected, is there any workaround or issues with version 2.4 and above of Spring Boot, please?