Mapping 推土机,自定义转换器上的实例化异常
我已经编写了自己的客户转换器:Mapping 推土机,自定义转换器上的实例化异常,mapping,converter,dozer,instantiationexception,Mapping,Converter,Dozer,Instantiationexception,我已经编写了自己的客户转换器: public class MyFancyCustomConverter extends DozerConverter<Integer, AnObject> { public MyFancyCustomConverter(Class<Integer> prototypeA, Class<AnObject> prototypeB) { super(prototypeA, prototypeB);
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;
}
}
公共类MyFancyCustomConverter扩展了DozerConverter
{
公共MyFancyCustomConverter(类原型A、类原型B)
{
超级(原型A,原型B);
}
@凌驾
公共对象转换为(整数源、对象目标)
{
//托多:做点什么
返回null;
}
@凌驾
公共整数转换源(对象源、整数目标)
{
//托多:做点什么
返回0;
}
}
和my 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>
java.lang.Integer
xyz.AnObject
这
这
但我有一个例外:
org.dozer.MappingException:java.lang.InstanceionException:xyz.MyFancyCustomConverter
知道我做错了什么吗?我猜这是因为MyFancyCustomConverter没有默认的转换器。但我不能添加一个,因为DozerConverter没有一个
public MyFancyCustomConverter(Class<Integer> prototypeA, Class<AnObject> prototypeB)
{
super(prototypeA, prototypeB);
}
超类需要知道这两个类的运行时类型,并且由于类型擦除,需要传入一个类型令牌。请添加完整的stacktrace
public MyFancyCustomConverter()
{
super(Integer.class, AnObject.class);
}