两个类具有相同的XML类型名称

两个类具有相同的XML类型名称

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

问题描述

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



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

错误

 由此引起:com.sun .xml.internal.bind.v2.runtime.IllegalAnnotationsException:IllegalAnnotationExceptions的2个计数
两个类具有相同的XML类型名称{http://test.au/schema/namesearch}InfoSource。使用@ XmlType.name和@ XmlType.namespace为它们分配不同的名称。
此问题与以下位置有关:
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 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

InfoSource

  @ XmlAccessorType(XmlAccessType.FIELD)
@Xml类型(name =InfoSource,propOrder = {
infoSource
})

公共类InfoSource {

@XmlElement
受保护的列表< String> infoSource;

NameSearchFilters

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

})
公共类NameSearchFilters {

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

SearchRequest

  @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;

为什么这里有问题?

解决方案

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


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

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

error

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

InfoSource

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

public class InfoSource {

    @XmlElement
    protected List<String> infoSource;

NameSearchFilters

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

})
public class NameSearchFilters {

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

SearchRequest

@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;

Why is there problem here?

解决方案

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

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

08-14 05:45