我正在使用 JAXB 基于一些 XSD 模式生成 java 类。对于元素,例如:
<xsd:element name="REC_LOC" type="xsd:string" minOccurs="1"/>
jaxb 生成以下代码:
@XmlElement(name = "REC_LOC", required = true)
protected String recloc;
public String getRECLOC() {
return recloc;
}
/**
* Sets the value of the recloc property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setRECLOC(String value) {
this.recloc = value;
}
Run Code Online (Sandbox Code Playgroud)
问题是我们需要使用一些依赖于 getter/setter 方法命名约定的专有 XML 工具。例如,对于字段 REC_LOC,他们期望调用 getRecLoc(String value) 和 setRecLoc() 的方法,而不是 getRECLOC()。
有没有办法自定义jaxb生成的方法名?