Jaxb Moxy正在编组未映射的java属性

Jaxb Moxy正在编组未映射的java属性,jaxb,moxy,Jaxb,Moxy,我能够按照以下步骤使用XML作为外部元数据。但是,Moxy正在编组外部XML元数据中既没有注释也没有指定的属性。下面是示例,例如如何避免这种行为?我尝试使用xmlmappingmetadata complete=“true”,但没有任何帮助 添加了新前缀属性的类(为简洁起见删除了其他属性) 元数据xml <xml-bindings xmlns="http://www.eclipse.org/eclipselink/xsds/persistence/oxm" package-name="bl

我能够按照以下步骤使用XML作为外部元数据。但是,Moxy正在编组外部XML元数据中既没有注释也没有指定的属性。下面是示例,例如如何避免这种行为?我尝试使用
xmlmappingmetadata complete=“true”
,但没有任何帮助

添加了新前缀属性的类(为简洁起见删除了其他属性)

元数据xml

<xml-bindings xmlns="http://www.eclipse.org/eclipselink/xsds/persistence/oxm" package-name="blog.bindingfile">
   <xml-schema namespace="http://www.example.com/customer" element-form-default="QUALIFIED" />
   <java-types>
      <java-type name="Customer">
         <xml-root-element />
         <xml-type prop-order="firstName lastName address phoneNumbers" />
         <java-attributes>
            <xml-element java-attribute="firstName" name="first-name" />
            <xml-element java-attribute="lastName" name="last-name" />
            <xml-element java-attribute="phoneNumbers" name="phone-number" />
         </java-attributes>
      </java-type>
      <java-type name="PhoneNumber">
         <java-attributes>
            <xml-attribute java-attribute="type" />
            <xml-value java-attribute="number" />
         </java-attributes>
      </java-type>
   </java-types>
</xml-bindings>

输出

<customer xmlns="http://www.example.com/customer">
   <first-name>Jane</first-name>
   <last-name>Doe</last-name>
   <address>
      <street>123 A Street</street>
   </address>
   <phone-number type="work">555-1111</phone-number>
   <phone-number type="cell">555-2222</phone-number>
   <prefix>pre</prefix>
</customer>

简
雌鹿
A街123号
555-1111
555-2222
之前

要从封送的XML中省略
前缀
属性,应在绑定文件中将其声明为
瞬态

  ...
  <java-type name="Customer">
     <xml-root-element />
     <xml-type prop-order="firstName lastName address phoneNumbers" />
     <java-attributes>
        <xml-element java-attribute="firstName" name="first-name" />
        <xml-element java-attribute="lastName" name="last-name" />
        <xml-element java-attribute="phoneNumbers" name="phone-number" />
        <xml-transient java-attribute="prefix" />
     </java-attributes>
  </java-type>
  ...
。。。
...
默认情况下,JAXB将映射任何公共字段,因此由于
前缀
字段上没有显式的“注释”,因此它以默认方式映射

xml-mapping-metadata-complete=“true”
的意思是“忽略Java类中的任何注释,并将此绑定文件用作映射信息的唯一来源——不要增加任何现有注释。”

希望这有帮助,
里克

谢谢你。仍在尝试挂起“通过异常配置;-)”。你能看看这是不是一个bug吗
  ...
  <java-type name="Customer">
     <xml-root-element />
     <xml-type prop-order="firstName lastName address phoneNumbers" />
     <java-attributes>
        <xml-element java-attribute="firstName" name="first-name" />
        <xml-element java-attribute="lastName" name="last-name" />
        <xml-element java-attribute="phoneNumbers" name="phone-number" />
        <xml-transient java-attribute="prefix" />
     </java-attributes>
  </java-type>
  ...