JAXB 编译器和属性顺序 [英] JAXB Compiler and Attribute Order

查看:33
本文介绍了JAXB 编译器和属性顺序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想控制 JAXB 编译器生成的 .java 文件中的属性顺序.

I would like to control the attribute order in .java files generated by the JAXB compiler.

我知道属性顺序对于 xml 验证并不重要.该顺序对于回归测试环境中编组 xml 的文本比较很重要.文件中属性的顺序直接影响编组的 xml 标签中的属性顺序.

I'm aware that attribute order is not important for xml validation. The order is important for textual comparison of marshalled xml in a regression test environment. The order of attributes in a file directly affects the order of the attributes in marshalled xml tags.

每次运行 JAXB 编译器时,属性组都会以不同的顺序出现,即使架构没有更改.编译器上没有明显的选项来防止这种行为.

Every time the JAXB compiler is run attribute groups appear in a different order, even with no changes to the schema. There is no apparent option available on the compiler to prevent this behavior.

我想避免运行编译后脚本来按字母顺序对生成的 .java 文件中的属性重新排序,因为这会破坏属性组,但我不确定是否还有其他选择.

I would like to avoid running a post-compilation script to alphabetically reorder attributes in the generated .java files since this breaks up the attribute groups, but I'm not sure there is another option.

非常感谢任何建议.

谢谢,戴夫

推荐答案

显然,在 JAXB 2.0 中你可以使用注解 @XmlAccessorOrder 或 @XmlType(propOrder=)

Apparently, in JAXB 2.0 you can use the annotation @XmlAccessorOrder or @XmlType(propOrder=)

这篇关于JAXB 编译器和属性顺序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆