JAXB marshaller no-arg默认构造函数 [英] JAXB marshaller no-arg default constructor
本文介绍了JAXB marshaller no-arg默认构造函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想从java库编组java对象。
I would like to marshalling a java object from a java library.
当使用JAXB marschaller编组java对象时,我遇到了一个问题:
When marshalling a java object using JAXB marschaller, I have got a problem:
A类没有no-arg默认构造函数
class A does not have a no-arg default constructor
我用Java Decomplier来检查类的实现,它是像这样:
I used a Java Decomplier to check the class a implementation, it is like this:
public final class AImpl
implements A
这意味着我无法扩展类 AImpl
。
That means I can not extends class AImpl
.
那么如何使用no-arg默认构造函数修复问题?
So How can I fix the problem with no-arg default constructor?
推荐答案
您可以使用 此用例的XmlAdapter
。有关示例,请参阅:
You can use XmlAdapter
for this use case. For an example see:
- http://bdoughan.blogspot.com/2010/12/jaxb-and-immutable-objects.html
- http://bdoughan.blogspot.com/2010/07/xmladapter-jaxbs-secret-weapon.html
- http://bdoughan.blogspot.com/2010/12/jaxb-and-immutable-objects.html
- http://bdoughan.blogspot.com/2010/07/xmladapter-jaxbs-secret-weapon.html
这篇关于JAXB marshaller no-arg默认构造函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文