java通过xstream将xml转换为java对象遇到的问题(一个对像中两个子类的类名相同)

在做xml转换为java对象时,大对象中存在两个类名所对应的别名相同 如:

1.     @XStreamAlias(value="Benefit")
 public class Item08Benefit {

2. @XStreamAlias(value="Benefit")
public class Item39Bene {

以上两个类对应的别名相同,造成解析成对象时xsteam不知道找哪个类

错误信息为:

com.thoughtworks.xstream.converters.ConversionException: Element Benefit of type com.isoftstone.mipss.entity.item.Item39Bene is not defined as field in type com.isoftstone.mipss.entity.item.Item08

  

解决方案:

在调用类的地方加上如下代码:

 @XStreamAlias(impl=Item08Benefit.class,value="Benefit")
 @XStreamImplicit
    private List<Item08Benefit> benefit;

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值