简体   繁体   English

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

[英]Two Classes have same XML type name

Im having this error where it says that i have two classes of same XML type name我有这个错误,它说我有两个相同的 XML 类型名称的类

so the problem is between InfoSource -> NameSearchFilters -> SearchRequest所以问题出在 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?为什么这里有问题?

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

Situation like this throws exception 'x counts of IllegalAnnotationExceptions'像这样的情况会抛出异常 'x counts of IllegalAnnotationExceptions'

class A{} A级{}
class B extends A{} B 类扩展 A{}
class C extends A{} C 类扩展 A{}

Resolve problem adding annotation into class A like this:解决在类 A 中添加注释的问题,如下所示:

@XmlTransient @XmlTransient
public class A公开课A
{} {}

@XmlType(name = "Info_Source", propOrder = { "infoSource" @XmlType(name = "Info_Source", propOrder = { "infoSource"

Try this in code在代码中试试这个

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 两个类具有相同的XML类型名称“objectFactory” - Two classes have the same XML type name “objectFactory” IllegalAnnotationException:两个类具有相同的 XML 类型名称 - IllegalAnnotationException: Two classes have the same XML type name 使用两个类具有相同的 XML 类型名称 - Use two classes have the same XML type name wsdl2java两个类具有相同的XML类型名称“{http://***.***。$。* * / * / / / / / *}} objectFactory” - wsdl2java Two classes have the same XML type name “{http://***.***.***.***/***/***/***}objectFactory” IllegalAnnotationExceptions:两个类具有相同的XML类型名称。 CXF插件生成的代码 - IllegalAnnotationExceptions: Two classes have the same XML type name. Code generated by CXF plugin java +消费SOAP Web服务+“两个类具有相同的XML类型名称……” - java + Consuming a SOAP web service + “Two classes Have the same XML type name …” 获取 JAXB 异常,例如“两个类具有相同的 XML 类型名称...” - Getting the JAXB exception like "Two classes have the same XML type name..." jaxb2-maven-plugin 在生成 xsd 时忽略命名空间 - 两个类具有相同的 XML 类型 - jaxb2-maven-plugin ignores namespace when generating xsd - Two classes have the same XML type 如何创建两个具有相同名称,签名和返回类型的方法的类,就像它们实现相同的接口一样 - How to make two classes which both have method with the same name, signature and return type behave like they would implement the same interface 我的 Java 应用程序中的两个类具有相同的限定名称 - Two classes in my java app have the same Qualified name
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM