我试图用orika将字符串Map到uuid,但出现以下错误:
发生sourcetype=java.lang.string destinationtype=java.util.uuid错误:没有为从字符串到uuid的转换注册转换器,也没有任何可以从字符串生成uuid的objectfactory
public class SourceType {
private String firstId;
//setters getters
}
public class DestinationType {
private UUID firstId;
//setters getters
}
mapperFactory.classMap(SourceType.class, DestinationType.class)
.byDefault()
.customize(new MyCustomMapper())
.register();
private final class MyCustomMapper extends CustomMapper<SourceType, DestinationType> {
@Override
public void mapAtoB(final SourceType sourceType, final DestinationType destinationType, final MappingContext context) {
destinationType.setFirstId(UUID.fromString(sourceType.getFirstId()));
}
}
暂无答案!
目前还没有任何答案,快来回答吧!