gpt4 book ai didi

java - JAXBException UnmarshallerImpl 及其任何父类(super class)在此上下文中都是已知的

转载 作者:行者123 更新时间:2023-11-29 09:01:13 25 4
gpt4 key购买 nike

在整理我的 Java 代码时:

      Marshaller marshaller = context.createMarshaller();
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
marshaller.marshal(um, new File("temp.xml"));

我遇到了这个异常:

Exception in thread "main" javax.xml.bind.JAXBException: class com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallerImpl nor any of its super class is known to this context.
at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.getBeanInfo(Unknown Source)
at com.sun.xml.internal.bind.v2.runtime.MarshallerImpl.write(Unknown Source)
at com.sun.xml.internal.bind.v2.runtime.MarshallerImpl.marshal(Unknown Source)
at javax.xml.bind.helpers.AbstractMarshallerImpl.marshal(Unknown Source)
at App.main(App.java:47)

最佳答案

有几件事可能会导致异常:

可能性#1

您的一个域对象持有 UnmarshallerImpl 的实例。我建议不要这样做。如果您觉得必须,那么您应该使用 @XmlTransient 注释该字段/属性。

可能性 #2

正如 Ian Roberts 评论所建议的,您可能不小心编码了 um 变量的 UnmarshallerImpl 实例持有您的 Unmarshaller 实例.

关于java - JAXBException UnmarshallerImpl 及其任何父类(super class)在此上下文中都是已知的,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17340403/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com