jaxb 版本 2.0 不使用 xmlrootelement 中的 name 属性
我已将 jaxb 库更新到版本 2.0。 我正在使用以下 jar,jaxb-api-2.0.jar 和 jaxb-imp-2.0.jar。 现在的问题是,它没有使用 @XmlRootElement(name="something")。 但在以前的库的帮助下,该 xml 在生成的 xml 中使用了定义的名称“something”。现在它采用驼峰式大小写的类名,而不是名称属性中定义的“某物”。这是最新的 jaxb 库的错误吗?请帮忙!
I have updated the jaxb library to version 2.0.
I am using the following jars, jaxb-api-2.0.jar and jaxb-imp-2.0.jar.
Now the problem is, it's not using the @XmlRootElement(name="something").
But with the help of previous library, the xml used the defined name "something" in the generated xml. Right now it's taking the class name in camel case instead of "something" defined in the name attribute. Is it a bug of latest jaxb library? Please help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
下面是一个可能有帮助的示例。
@XmlRootElement
注释将控制 XML 文档的根元素的名称。如果要控制内部元素的名称,可以使用 @XmlElement 注释。SomeObject
SomethingElse
输出
Below is an example that may help. The
@XmlRootElement
annotation will control the name of the root element for the XML document. If you want to control the name of an inner element you can use the@XmlElement
annotation.SomeObject
SomethingElse
Output
在我的子班中,我使用 @XmlRootElement(name="some-thing")。除此之外,当我使用 @XmlType(name="some-thing") 时,我的问题得到了解决!
In my child class I was using the @XmlRootElement(name="some-thing"). In addition to it, when I use @XmlType(name="some-thing") my problem got resolved!