How do we exclude fields of source in mapping?
I skimmed over the documentation and found nothing on this one. The closest thing I found was mapstruct.unmappedTargetPolicy.
My scenario is that I have a source like this for example
public Class UserDTO {
private String userName;
private String password;
private String confirmPassword;
// getters and setters
}
But I have a target object like this
public class User {
private String userName;
private String password;
// getters and setters
}
As of now, it throws an exception since it can't find a setter in the target.
it throws an exception since it can't find a setter in the target
That's surprising, can you share the exact exception? Source properties not present in the target will be ignored. Only if you mapped a User to a User DTO you should get a warning about the unmapped confirmPassword which you could disable via @Mapping#ignore.
Sorry this is my bad. It was Thymeleaf throwing NotReadablePropertyException.