两个类具有相同的 XML 类型名称 [英] Two Classes have same XML type name

查看:30
本文介绍了两个类具有相同的 XML 类型名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了这个错误,它说我有两个类的 XML 类型名称相同

Im having this error where it says that i have two classes of same XML type name

所以问题出在 InfoSource -> NameSearchFilters -> SearchRequest

so the problem is between InfoSource -> NameSearchFilters -> SearchRequest

错误

Caused by: com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException: 2 counts of IllegalAnnotationExceptions
Two classes have the same XML type name "{http://test.au/schema/namesearch}InfoSource". Use @XmlType.name and @XmlType.namespace to assign different names to them.
    this problem is related to the following location:
        at au.test.identitySearch.model.InfoSource
        at protected au.test.identitySearch.model.InfoSource au.test.identitySearch.model.nameSearch.NameSearchFilters.infoSourceList
        at au.test.identitySearch.model.nameSearch.NameSearchFilters
    this problem is related to the following location:
        at au.test.identitySearch.model.InfoSource
        at protected au.test.identitySearch.model.InfoSource au.test.identitySearch.model.nameSearch.NameSearchFilters.infoSourceList
        at au.test.identitySearch.model.nameSearch.NameSearchFilters
        at protected au.test.identitySearch.model.nameSearch.NameSearchFilters au.test.identitySearch.ws.model.SearchRequest.searchFilters
        at au.test.identitySearch.ws.model.SearchRequest

信息来源

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "InfoSource", propOrder = {
    "infoSource"
})

public class InfoSource {

    @XmlElement
    protected List<String> infoSource;

名称搜索过滤器

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "NameSearchFilters", propOrder = {

})
public class NameSearchFilters {

    @XmlElement
    protected InfoSource infoSourceList;
    @XmlElement
    protected String nameType;

搜索请求

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
    "searchControls",
    "searchCriteria",
    "searchFilters"
})
@XmlRootElement(name = "searchRequest")
public class SearchRequest {

    @XmlElement(required = true)
    protected SearchControls searchControls;
    @XmlElement(required = true)
    protected NameSearchCriteria searchCriteria;
    @XmlElement
    protected NameSearchFilters searchFilters;

为什么这里有问题?

推荐答案

您是否尝试过为每个命名空间属性添加不同的值,例如 @XmlType(namespace="test1", name = "InfoSource", propOrder= { "infoSource" }) ) ?

Did you try adding different values of namespace attribute to each of them like @XmlType(namespace="test1", name = "InfoSource", propOrder = { "infoSource" }) ) ?

这篇关于两个类具有相同的 XML 类型名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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