2
我有这个模式,我使用JAXB生成java存根文件。JAXB绑定 - 定义列表的返回类型<T>方法
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:c="http://www.a.com/f/models/types/common"
targetNamespace="http://www.a.com/f/models/types/common"
elementFormDefault="qualified">
<xs:complexType name="constants">
<xs:sequence>
<xs:element name="constant" type="c:constant" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="constant">
<xs:sequence>
<xs:element name="reference" type="c:reference"/>
</xs:sequence>
<xs:attribute name="name" use="required" type="xs:string"/>
<xs:attribute name="type" use="required" type="c:data-type"/>
</xs:complexType>
默认的Java包的名称是“com.afmodels.types.common”
我也有“常量”和“常量”定义的包“com.afmodel.common现有的接口'我想要生成的类使用哪个 。我使用的JAXB绑定文件,以确保生成的Java类实现 所需的接口
<jxb:bindings schemaLocation="./commonmodel.xsd" node="/xs:schema">
<jxb:bindings node="xs:complexType[@name='constants']">
<jxb:class/>
<inheritance:implements>com.a.f.model.common.Constants</inheritance:implements>
</jxb:bindings>
下生成的类并实现了正确的接口
package com.a.f.models.types.common;
..
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "constants", propOrder = {
"constant"
})
public class Constants
implements com.a.f.model.common.Constants
{
@XmlElement(required = true)
protected List<Constant> constant;
public List<Constant> getConstant() {
但返回类型清单<> getConstant()方法不正确。我需要这是
public List<com.a.f.model.common.Constant> getConstant() {
是否有通过jaxb绑定文件做到这一点?