解决方式:在接口中定义方法传入参数、返回参数为对一个的类型,mapstruct的实现类会自动调用该方法。
代码:
@Mapper(builder = @Builder(disableBuilder = true)) public interface StlmtCheckingResultConvert { StlmtCheckingResultConvert INSTANCE = Mappers.getMapper(StlmtCheckingResultConvert.class); default LocalDateTime transactionDateToLocalDateTime(final LocalDate transactionDate) { return LocalDateTime.of(transactionDate, LocalTime.MAX); } default LocalDate transactionLocalDateTimeToDate(final LocalDateTime transactionDate) { return transactionDate.toLocalDate(); }
参考:https://stackoverflow.com/questions/72389940/mapstruct-conversion-from-date-to-localdatetime