例如,xsd 中的 sOmE_PROPerty 必须是 java 类中的 sOmE_PROPerty 而不是 someProperty。
我尝试使用 globalBindings enableJavaNamingConventions="false"但它不起作用。
最佳答案
通过更改类 com.sun.xml.bind.api.impl.NameConverter 中的 jaxb 的源代码来解决,如下所示:
public static final NameConverter standard = new Standard();
static class Standard extends NameUtil implements NameConverter {
public String toClassName(String s) {
return s;//toMixedCaseName(toWordList(s), true);
}
public String toVariableName(String s) {
return s;//toMixedCaseName(toWordList(s), false);
}
public String toInterfaceName( String token ) {
return token;//toClassName(token);
}
public String toPropertyName(String s) {
String prop = s;//toClassName(s);
// property name "Class" with collide with Object.getClass,
// so escape this.
if(prop.equals("Class"))
prop = "Clazz";
return prop;
}
关于jaxb - 如何在 xjc 中禁用 Java 命名约定?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6267478/