gpt4 book ai didi

java - 将 Powerclass 用于使用 JAXB 的测试类时出现链接错误

转载 作者:行者123 更新时间:2023-12-02 01:59:56 24 4
gpt4 key购买 nike

`java.lang.LinkageError: loader constraint violation: when resolving overridden method "com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.createUnmarshal

`Exception(Lorg/xml/sax/SAXException;)Ljavax/xml/bind/UnmarshalException;" the class loader (instance of org/powermock/core/classloader/MockClassLoader) of the current class, com/sun/xml/bind/v2/runtime/unmarshaller/UnmarshallerImpl, and its superclass loader (instance of <bootloader>), have different Class objects for the type org/xml/sax/SAXException used in the signature

我正在使用 Powermock 在 JUNIT 测试用例中模拟静态类。由于我的 junit 使用 xml 文件,因此我收到了一些错误,并且我必须使用 powermock 忽略,如下所示。

@PowerMockIgnore({ "javax.xml.*"})
@RunWith(PowerMockRunner.class)

我收到链接错误以及以下错误。请指教

javax.xml.transform.TransformerFactoryConfigurationError: Provider for class javax.xml.transform.TransformerFactory cannot be created

最佳答案

我在 powermockignore 中使用了所有三个导入后问题已解决

@PowerMockIgnore({
"javax.xml.*",
"org.xml.*",
"org.w3c.*"
})

关于java - 将 Powerclass 用于使用 JAXB 的测试类时出现链接错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51755308/

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