Har*_*ish 1 java junit jaxb powermock powermockito
`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
Run Code Online (Sandbox Code Playgroud)
我正在使用 Powermock 在 JUNIT 测试用例中模拟静态类。由于我的 junit 使用 xml 文件,所以我收到了一些错误,我必须使用 powermock 忽略,如下所示。
@PowerMockIgnore({ "javax.xml.*"})
@RunWith(PowerMockRunner.class)
Run Code Online (Sandbox Code Playgroud)
我收到链接错误以及以下错误。请指教
javax.xml.transform.TransformerFactoryConfigurationError: Provider for class javax.xml.transform.TransformerFactory cannot be created
Run Code Online (Sandbox Code Playgroud)
我在 powermockignore 中使用了所有三个导入后问题解决了
@PowerMockIgnore({
"javax.xml.*",
"org.xml.*",
"org.w3c.*"
})
Run Code Online (Sandbox Code Playgroud)