我写了自己的客户转换器:
public class MyFancyCustomConverter extends DozerConverter<Integer, AnObject>
{
public MyFancyCustomConverter(Class<Integer> prototypeA, Class<AnObject> prototypeB)
{
super(prototypeA, prototypeB);
}
@Override
public AnObject convertTo(Integer source, AnObject destination)
{
// TODO: do something
return null;
}
@Override
public Integer convertFrom(AnObject source, Integer destination)
{
// TODO: do something
return 0;
}
}
还有我的mapping.xml:
<mapping>
<class-a>java.lang.Integer</class-a>
<class-b>xyz.AnObject</class-b>
<field custom-converter="xyz.MyFancyCustomConverter" custom-converter-param="hello">
<a>this</a>
<b key="my.key">this</b>
</field>
</mapping>
但我得到了这个例外:
org.dozer.MappingException: java.lang.InstantiationException: xyz.MyFancyCustomConverter
知道我做错了什么吗?我想这是因为 MyFancyCustomConverter 没有默认转换器。但我不能添加一个,因为 DozerConverter 没有一个......