简体   繁体   English

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

[英]cxf-codegen adding superfluous underscore in enum member name

I have the following generated enumeration type. 我有以下生成的枚举类型。 The issue I have is that for some reason (presumably capitalisation) that an underscore is inserted in the NCBonus value. 我遇到的问题是,由于某种原因(大概是大写),在NCBonus值中插入了下划线。

I would like to know how I can prevent that from happening when generating the enumeration. 我想知道如何在生成枚举时防止这种情况发生。

 * 
 * <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");

I have tried using the global bindings option 我尝试使用全局绑定选项

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

which has undesired consequences on other objects but makes no different to the enum type. 这会对其他对象产生不良影响,但与枚举类型没有区别。

In addition I have tried using 另外我试过使用

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

all to no avail. 一切都无济于事。

Could someone please advise how I can achieve this goal please. 有人可以建议我如何实现这个目标。

The answer that worked for me was to move the jaxb bindings out of the jaxws bindings file. 对我有用的答案是将jaxb绑定移出jaxws绑定文件。

jaxb_bindings.xml 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 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 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> 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM