更新
这个问题可能指的
ObjectFactory是创建一个角色的作用
JAXBContext。如果
JAXBContext在上下文路径上引导a
,则它将在该位置检查ObjectFactory以确定该包中的类:
- http://bdoughan.blogspot.com/2010/09/processing-atom-feeds-with-jaxb.html
如果您没有在上下文路径上
ObjectFactory创建一个,但仍希望
JAXBContext在路径上创建您,则可以
jaxb.index在该包中包含一个名为的文件,列出要包含在其中的文件
JAXBContext(被引用的类将自动插入):
- http://bdoughan.blogspot.com/2010/08/using-xmlanyelement-to-build-generic.html
另外,您可以引导您
JAXBContext到一系列类而不是上下文路径上:
- http://bdoughan.blogspot.com/2010/11/jaxb-and-inheritance-using-xsitype.html
是否需要ObjectFactory
一个
ObjectFactory是不需要的,从Java类有使用情况下,您可以利用带注释的相似课程开始,虽然即使
@XmlRegistry在为了使用
@XmlElementDecl注释。
创建一个JAXBElement的实例
您随时可以
JAXBElement直接创建:
final JAXBElement<WebLeads> webLeadsElement = new JAXBElement<WebLeads>( new QName("root-element-name"), WebLeads.class, webLeadsJavaObj);JAXBElement的替代
或者,由于JAXBElement仅用于提供根元素信息,因此可以使用以下注释
WebLeads类
@XmlRootElement:
@XmlRootElement(name="root-element-name")public class WebLeads { ...}


