cxf-codegen 在枚举成员名称中添加多余的下划线

cxf-codegen adding superfluous underscore in enum member name

我有以下生成的枚举类型。我遇到的问题是出于某种原因(大概是大写)在 NCBonus 值中插入了下划线。

我想知道如何在生成枚举时防止这种情况发生。

 * 
 * <p>The following schema fragment specifies the expected content contained within this class.
 * <p>
 * <pre>
 * &lt;simpleType name="PromoType">
 *   &lt;restriction base="{http://www.w3.org/2001/XMLSchema}string">
 *     &lt;enumeration value="MEM"/>
 *     &lt;enumeration value="COU"/>
 *     &lt;enumeration value="CHA"/>
 *     &lt;enumeration value="SAD"/>
 *     &lt;enumeration value="NCBonus"/>
 *   &lt;/restriction>
 * &lt;/simpleType>
 * </pre>
 * 
 */
@XmlType(name = "PromoType")
@XmlEnum
public enum PromoType {

    MEM("MEM"),
    COU("COU"),
    CHA("CHA"),
    SAD("SAD"),
    @XmlEnumValue("NCBonus")
    NC_BONUS("NCBonus");

我试过使用全局绑定选项

   <jxb:globalBindings underscoreBinding="asCharInWord" xmlns:xs="http://www.w3.org/2001/XMLSchema">

这对其他对象有不良影响,但对枚举类型没有影响。

另外我试过用

<jaxb:bindings schemaLocation="../schemas/insurance_service_model.xsd" node="//xs:schema">
    <jaxb:bindings node="xs:simpleType[@name='PromoType']">
        <jaxb:typesafeEnumMember name="NCBonus" value="NCBonus"/>

都无济于事。

有人可以告诉我如何实现这个目标吗?

对我有用的答案是将 jaxb 绑定移出 jaxws 绑定文件。

jaxb_bindings.xml

<jaxb:bindings xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
                xmlns:xsd="http://www.w3.org/2001/XMLSchema"
                jaxb:version="2.0">

    <jaxb:bindings schemaLocation="../schemas/insurance_service_model.xsd">
        <jaxb:bindings node="//xsd:simpleType[@name='PromoType']">
            <jaxb:typesafeEnumClass name="PromoType">
                <jaxb:typesafeEnumMember name="NCBonus" value="NCBonus"/>
            </jaxb:typesafeEnumClass>
        </jaxb:bindings>
    </jaxb:bindings>

</jaxb:bindings>

wsdl_bindings.xml

<?xml version="1.0" encoding="UTF-8"?>

<jaxws:bindings
        xmlns:xsd="http://www.w3.org/2001/XMLSchema"
        xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
        wsdlLocation="../wsdl/insurance_service.wsdl"
        xmlns="http://java.sun.com/xml/ns/jaxws"
        xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
        xmlns:jaxws="http://java.sun.com/xml/ns/jaxws">

    <jaxws:enableWrapperStyle>false</jaxws:enableWrapperStyle>

</jaxws:bindings>

pom.xml

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-codegen-plugin</artifactId>
            <version>${cxf.codegen.version}</version>
            <executions>
                <execution>
                    <id>csg</id>
                    <phase>generate-sources</phase>
                    <configuration>
                        <wsdlOptions>
                            <wsdlOption>
                                <wsdl>${project.basedir}/src/main/resources/v2_3/wsdl/insurance_service.wsdl</wsdl>
                                <extraargs>
                                    <extraarg>-xjc-verbose</extraarg>
                                    <extraarg>-verbose</extraarg>
                                </extraargs>
                                <bindingFiles>
                                    <bindingFile>${project.basedir}/src/main/resources/common_binding.xml</bindingFile>
                                    <bindingFile>${project.basedir}/src/main/resources/v2_3/bindings/wsdl_binding.xml</bindingFile>
                                    <bindingFile>${project.basedir}/src/main/resources/v2_3/bindings/jaxb_bindings.xml</bindingFile>
                                </bindingFiles>
                            </wsdlOption>
                        </wsdlOptions>
                    </configuration>
                    <goals>
                        <goal>wsdl2java</goal>
                    </goals>
                </execution>

            </executions>