IntelliJ 使用 NoClassDefFoundError 随机无法为 Spring JUnit 测试加载 ApplicationContext

外行

我无法粘贴整个堆栈跟踪,但通常情况下,通过命令行正常工作并且最后一次通过 IDE 正常工作的单元测试在通过 IntelliJ 运行时突然开始失败。它总是像

java.lang.IllegalStateException: Failed to load ApplicationContext
...
...Long meaningless stack trace
...
Caused by: org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are:
PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property 'serviceClass' threw exception; nested exception is java.lang.NoClassDefFoundError: javax/xml/ws/soap/MTOM
...
...Even more generic stack trace

...

这尤其令人困惑,因为它找不到的类是类似的默认 lib 类。将它无法找到的类添加到 Maven 依赖项有时有助于作为管道胶带解决方案,但通常每次都是不同的类,即使问题基本相同。什么可能导致这种情况?

外行

我能够解决这个问题。显然,IntelliJ 默认 JRE 设置为使用 Java 10,但系统默认设置为 Java 8。将其切换到 Java 8 就成功了。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

使用Mybatis Crud的Spring MVC:使用Junit测试时,错误无法加载ApplicationContext

无法加载ApplicationContext:Spring和Junit

Spring,无法在测试中加载ApplicationContext

在Spring Boot测试中无法加载ApplicationContext

是否可以使用Spring ApplicationContext中的bean参数化JUnit Jupiter测试?

运行Spring Boot集成测试时无法加载ApplicationContext

使用IntelliJ运行JUnit测试

使用IntelliJ创建Junit测试

无法使用Spring进行JUnit测试

无法使用 JUnit 测试 spring 注入

使用 ApplicationContext 运行 JUnit 测试时禁用 Hazelcast 实例

无法在Spring中加载applicationContext.xml

Spring无法从ApplicationContext xml文件加载类

春季启动应用程序。无法在JUnit测试中加载ApplicationContext

JUnit错误:无法加载ApplicationContext:违规资源:类路径资源

添加Hibernate Validator时无法在JUnit中加载ApplicationContext

JUnit 5-使用JUnit Jupiter引擎时,IntelliJ IDEA中的测试套件为空

JUnit测试遇到NoClassDefFoundError

没有Spring Boot的Java Spring测试-错误java.lang.IllegalStateException:无法加载ApplicationContext

没有Spring Boot的Java Spring测试-错误java.lang.IllegalStateException:无法加载ApplicationContext

使用Spring Boot和JUnit5在Intellij中终止所有测试

尝试为Spring Boot App的黄瓜集成测试加载不同的属性?

如何使用Spring为JUnit测试注入ServletContext?

Spring Boot 控制器单元测试:无法加载 ApplicationContext

将Spring Boot 2.0.8升级到2.1.2-无法在测试中加载ApplicationContext

Spring Boot Controller测试:模拟服务需要下游对象,导致ApplicationContext无法加载

IntelliJ无法运行JUnit测试类

无法加载ApplicationContext。无法创建集成测试

Spring:无法使用PropertyPlaceholderConfigurer在junit上加载属性