小编Kum*_*aja的帖子

如何使用 JAXB 自定义绑定自定义生成的 Java 对象的字段名称?

我正在尝试为下面的示例 xsd 生成 JAXB 生成的对象。

<xs:complexType name="AddressType">   
      <xs:sequence>   
        <xs:element name="USA" type="xs:string"/>   
      </xs:sequence>   
   </xs:complexType>  
Run Code Online (Sandbox Code Playgroud)

没有任何自定义绑定生成的类是

@XmlAccessorType(XmlAccessType.FIELD)   
@XmlType(name = "AddressType", propOrder = {   
    "usa"  
})   
public class AddressType {   

    @XmlElement(name = "USA", required = true)   
    protected String usa;   

    /**  
     * Gets the value of the usa property.  
     *   
     * @return  
     *     possible object is  
     *     {@link String }  
     *       
     */  
    public String getUSA() {   
        return usa;   
    }   

    /**  
     * Sets the value of the usa property.  
     *   
     * @param value  
     *     allowed …
Run Code Online (Sandbox Code Playgroud)

jaxb2 jaxb2-maven-plugin

4
推荐指数
1
解决办法
3608
查看次数

标签 统计

jaxb2 ×1

jaxb2-maven-plugin ×1