Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/351.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 spring启动应用程序JAXB错误“;两个类具有相同的XML类型名称;_Java_Xml_Spring Boot_Jaxb - Fatal编程技术网

Java spring启动应用程序JAXB错误“;两个类具有相同的XML类型名称;

Java spring启动应用程序JAXB错误“;两个类具有相同的XML类型名称;,java,xml,spring-boot,jaxb,Java,Xml,Spring Boot,Jaxb,我在spring boot应用程序中遇到此错误: 两个类具有相同的XML类型名称 “{xyz}操作系统家庭类型”。使用@XmlType.name和 @XmlType.namespace为它们指定不同的名称 这些是我无法访问的jaxb类,因此上面推荐的解决方案不起作用。这是我创建的一个bean,它在setContextPath处失败: public Jaxb2Marshaller amqpMessageMarshaller() { Jaxb2Marshaller marshaller =

我在spring boot应用程序中遇到此错误:

两个类具有相同的XML类型名称 “{xyz}操作系统家庭类型”。使用@XmlType.name和 @XmlType.namespace为它们指定不同的名称

这些是我无法访问的jaxb类,因此上面推荐的解决方案不起作用。这是我创建的一个bean,它在
setContextPath
处失败:

public Jaxb2Marshaller amqpMessageMarshaller() {
    Jaxb2Marshaller marshaller = new Jaxb2Marshaller();
    marshaller.setContextPaths("abc.jaxb", "efg.jaxb");
    Map<String, Object> properties = new HashMap<>();
    properties.put(Marshaller.JAXB_FORMATTED_OUTPUT, true);
    properties.put(Marshaller.JAXB_ENCODING, "UTF-8");
    marshaller.setMarshallerProperties(properties);
    return marshaller;
public Jaxb2Marshaller amqpMessageMarshaller(){
Jaxb2Marshaller-marshaller=新的Jaxb2Marshaller();
setContextPath(“abc.jaxb”、“efg.jaxb”);
映射属性=新的HashMap();
put(Marshaller.JAXB_格式化的_输出,true);
put(Marshaller.JAXB_编码,“UTF-8”);
setMarshallerProperties(属性);
返回编组员;

这是否回答了您的问题?不,在这种情况下不起作用。他可以访问这些类并为它们添加名称空间。在我的情况下,这些是我无权访问的第三方类:(这是否回答了您的问题?不,在这种情况下不起作用。他可以访问这些类并为它们添加名称空间。在我的情况下,这些是我无权访问的第三方类。:(