本文介绍了如何在xjc中禁用Java命名约定?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
例如,xsd中的sOmE_PROPerty必须是java类中的sOmE_PROPerty而不是someProperty。
For example sOmE_PROPerty in xsd must be sOmE_PROPerty in java class not someProperty.
我尝试使用globalBindings enableJavaNamingConventions =false但它不起作用。
I tried to use globalBindings enableJavaNamingConventions="false" but it doesn't work.
推荐答案
通过更改类com.sun.xml.bind.api.impl.NameConverter中的jaxb源代码来解决:
Solved by changing source code of jaxb in class com.sun.xml.bind.api.impl.NameConverter like this:
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;
}
这篇关于如何在xjc中禁用Java命名约定?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!