[英]jaxb - marshalled root element with full java package
im working on a project with jaxb maven plugin. 我正在使用jaxb maven插件进行项目。 (maven 3.2.2, maven-jaxb2-plugin:0.8.1, java8)
(maven 3.2.2,maven-jaxb2-plugin:0.8.1,java8)
i use 我用
<bindingIncludes>
<bindingInclude>...</bindingInclude>
</bindingIncludes>
for specifing package of generated classes and 用于指定生成的类的包,以及
<generateDirectory>${project.build.directory}/generated-sources/xjc-dir
</generateDirectory>
for specifing output directory. 用于指定输出目录。
Im trying to understand what would cause marshaller to work in two different ways: 我试图了解会导致封送员以两种不同方式工作的原因:
actual: 实际:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<com.test.app.Foo>
...
</com.test.app.Foo>
expected: 预期:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Foo>
...
</Foo>
full java package is only visible for root element. 完整的Java包仅对根元素可见。
thanks in advance 提前致谢
edit: 编辑:
generated code 生成的代码
package com.test.app;
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
(...)
})
@XmlRootElement(name = "Foo")
public class Foo {
...
}
For any1 seeing similar issues: 对于任何看到类似问题的人:
in this case i was creating JAXBElement using my own QName using as one of arguments Foo.class.getName() 在这种情况下,我使用自己的QName作为参数Foo.class.getName()来创建JAXBElement。
removing JAXBElement totally and passing Foo to marshaller fixed the issue, using Foo.class.getSimpleName() would probably also work 完全删除JAXBElement并将Foo传递给编组可解决此问题,使用Foo.class.getSimpleName()可能也可以
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.