问题描述
使用JAXB生成Java类时,您将始终获得一个名为ObjectFactory的类.在此类中,有一个私有属性QName及其名称空间.
When you generate java classes with JAXB you'll always get a Class named ObjectFactory.In this class there is a private attribute QName with the namespace in it.
是否可以告诉生成器从外部访问此属性.那么也许将其公开或为其创建吸气剂?
Is it possible to tell the generator to make this attribute accessible from the outside. So maybe make it public or create a getter for it?
推荐答案
我相信只有ObjectFactory
需要创建JAXBElement<...>
实例的方法时,才会生成这些private static QName
字段.如果调用这些方法之一来获取JAXBElement
实例,则可以调用其getName
方法来检索与其关联的QName
.
I believe those private static QName
fields are only generated if the ObjectFactory
needs methods that create JAXBElement<...>
instances. If you call one of those methods to get a JAXBElement
instance, you can then invoke its getName
method to retrieve its associated QName
.
这篇关于JAXB使Objectfactory中的QName可访问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!