2
InstantiationException我寫我自己的客戶轉換器:推土機,自定義轉換器
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>
但我得到這個異常:
組織。 dozer.MappingException:java.lang.InstantiationException:xyz.MyFancyCustomConverter
任何想法我什麼做錯了嗎?我想這是因爲MyFancyCustomConverter沒有默認轉換器。但我不能添加一個,因爲DozerConverter沒有一個......
請添加完整的堆棧跟蹤 – Rytek