Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/327.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java JAXB在XML中添加不需要的标记并删除需要的标记_Java_Xml_Jaxb_Jersey_Marshalling - Fatal编程技术网

Java JAXB在XML中添加不需要的标记并删除需要的标记

Java JAXB在XML中添加不需要的标记并删除需要的标记,java,xml,jaxb,jersey,marshalling,Java,Xml,Jaxb,Jersey,Marshalling,我的课程结构如下: @XmlRootElement(name = "storage") @XmlType(propOrder = { "entries" }) @XmlAccessorType(XmlAccessType.FIELD) public class A { @XmlElement(name = "configuration") private Set<ClassB> entries; ... } @XmlRootElement(n

我的课程结构如下:

@XmlRootElement(name = "storage")
@XmlType(propOrder = {
        "entries"
})
@XmlAccessorType(XmlAccessType.FIELD)
public class A {
    @XmlElement(name = "configuration")
    private Set<ClassB> entries;
    ...
}

@XmlRootElement(name = "configuration")
@XmlType(propOrder = {
        "name",
        "entries"
})
@XmlAccessorType(XmlAccessType.FIELD)
public class B {
    private String name;
    @XmlElement(name = "configurationEntry")
    private Set<ClassC> entries;
    ...
}

@XmlRootElement(name = "configurationEntry")
@XmlType(propOrder = {
        "property1",
        "property2",
        "property3"
})
@XmlAccessorType(XmlAccessType.FIELD)
public class C {
    private String property1;
    private String property2;
    private String property3;
    ...
}
@XmlRootElement(name=“storage”)
@XmlType(比例器={
“条目”
})
@XmlAccessorType(XmlAccessType.FIELD)
公共A类{
@xmlement(name=“配置”)
私有集合条目;
...
}
@XmlRootElement(name=“配置”)
@XmlType(比例器={
“姓名”,
“条目”
})
@XmlAccessorType(XmlAccessType.FIELD)
公共B级{
私有字符串名称;
@XmlElement(name=“configurationEntry”)
私有集合条目;
...
}
@XmlRootElement(name=“configurationEntry”)
@XmlType(比例器={
“财产1”,
“物业2”,
“不动产3”
})
@XmlAccessorType(XmlAccessType.FIELD)
公共C类{
私有字符串属性1;
私有字符串属性2;
私有字符串属性3;
...
}
当我使用Jersey将其转换成XML时,当我尝试访问根容器(类A)时,会得到以下输出。我不知道为什么会有标签而不是标签

<Bes>
    <configuration>
        <name>Name1</name>
        <configurationEntry>
            <property1>...</property1>
            <property2>...</property2>
            <property3>...</property2>
        </configurationEntry>
        <configurationEntry>
            <property1>...</property1>
            <property2>...</property2>
            <property3>...</property2>
        </configurationEntry>
    </configuration>
    <configuration>
        <name>Name2</name>
        <configurationEntry>
            <property1>...</property1>
            <property2>...</property2>
            <property3>...</property2>
        </configurationEntry>
        <configurationEntry>
            <property1>...</property1>
            <property2>..</property2>
            <property3>...</property2>
        </configurationEntry>
    </configuration>
</Bes>

名称1
...
...
...
...
...
...
姓名2
...
...
...
...
..
...
当我尝试访问其中一个ClassB容器时,我得到以下结果。(与前一个问题类似),而不是我得到,没有包括标签

<Aes>
    <configurationEntry>
        <property1>...</property1>
        <property2>...</property2>
        <property3>...</property2>
    </configurationEntry>
    <configurationEntry>
        <property1>...</property1>
        <property2>...</property2>
        <property3>...</property2>
    </configurationEntry>
<Aes>

...
...
...
...
...
...
唯一一个按预期工作的是最低级别的C级

<configurationEntry>
    <property1>...</property1>
    <property2>...</property2>
    <property3>...</property2>
</configurationEntry>

...
...
...
为了清楚起见,我的期望输出如下:

访问存储(A类)容器时:

名称1
...
...
...
...
...
...
姓名2
...
...
...
...
..
...
当访问二级容器B类时,我希望:

名称1
...
...
...
...
...
...
C类适用于:

...
...
...

既然我看到了标签
没关系,我是个白痴

在我的客户代码中,出于某种原因,我分别检索
Set
Set
,而不是
A
B

<storage>
    <configuration>
        <name>Name1</name>
        <entries>
            <configurationEntry>
                <property1>...</property1>
                <property2>...</property2>
                <property3>...</property2>
            </configurationEntry>
            <configurationEntry>
                <property1>...</property1>
                <property2>...</property2>
                <property3>...</property2>
            </configurationEntry>
        </entries>
    </configuration>
    <configuration>
        <name>Name2</name>
        <entries>
            <configurationEntry>
                <property1>...</property1>
                <property2>...</property2>
                <property3>...</property2>
            </configurationEntry>
            <configurationEntry>
                <property1>...</property1>
                <property2>..</property2>
                <property3>...</property2>
            </configurationEntry>
        </entries>
    </configuration>
</storage>
<configuration>
    <name>Name1</name>
    <entries>
        <configurationEntry>
            <property1>...</property1>
            <property2>...</property2>
            <property3>...</property2>
        </configurationEntry>
        <configurationEntry>
            <property1>...</property1>
            <property2>...</property2>
            <property3>...</property2>
        </configurationEntry>
    </entries>
</configuration>
<configurationEntry>
    <property1>...</property1>
    <property2>...</property2>
    <property3>...</property2>
</configurationEntry>