我有一个在同一个类下有两个不同对象的类:
public class Customer {
//Source Attr
public Addr addr;
//target
public AddressDTO custAddr;
}
public class Addr {
public String street_Name;
public String home_Num;
public String post_code;
}
public class AddressDTO {
public String streetName;
public String homeNum;
public String postcode;
}
我正在尝试映射地址 - >客户对象中的AddressDTO对象:
ClassMapBuilder<?,?> classMapper = factory.classMap(Customer.class, Customer.class).classMap.field(addr.street_Name, custAddr.streetName).byDefault().register();
Customer source = new Customer();
source.setName("tester");
Addr addr = new Addr("streetname","123","456");
source.setAddr(addr);
Customer target = mapper.map(source,Customer.class);
当我运行时,我收到此错误:
引起:java.lang.IllegalArgumentException:java.lang.String是一个不受支持的源类,用于构造com.domain.AddressDTO的实例