我有这两个类:
public class CustomerEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private long id;
private String firstName;
private String lastName;
private String address;
private int age;
private LocalDateTime createdAt;
private LocalDateTime updatedAt;
}
Run Code Online (Sandbox Code Playgroud)
和
public class CustomerDto {
private Long customerId;
private String firstName;
private String lastName;
private Optional<String> address;
private int age;
}
Run Code Online (Sandbox Code Playgroud)
问题是 Mapstruct 无法识别可选变量“地址”。
任何人都知道如何解决它并让 Mapstruct 映射 Optional 字段?