这是因为LocalDate不是JavaBean(它没有零参数构造函数)
要解决此问题,您需要创建LocalDateConverter:
public class LocalDateConverter extends BidirectionalConverter<LocalDate, LocalDate> {
@Override
public LocalDate convertTo(LocalDate source, Type<LocalDate> destinationType) {
return (source);
}
@Override
public LocalDate convertFrom(LocalDate source, Type<LocalDate> destinationType) {
return (source);
}
}
Run Code Online (Sandbox Code Playgroud)
然后注册添加此行:
mapperFactory.getConverterFactory().registerConverter(new LocalDateConverter());
Run Code Online (Sandbox Code Playgroud)
作为shorcut,您可以按照Adam Michalik的建议注册提供的"PassThroughConverter",这样Orika就不会尝试实现新的"LocalDate":
mapperFactory.getConverterFactory().registerConverter(new PassThroughConverter(LocalDate.class));
Run Code Online (Sandbox Code Playgroud)