java - 添加测试依赖项后的 NoClassDefFoundError
问题描述
我在有线测试中添加了 hamcrest 方法,在构建过程中,它成功了。
但是当我尝试执行测试时,它抛出了java.lang.NoClassDefFoundError: org/hamcrest/Matchers
错误。
我尝试将 hamcerst 依赖项添加到包 pom 中,如下所示(即使依赖项已经存在于父 pom 中):
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-library</artifactId>
<scope>test</scope>
</dependency>
但是我NoClassDefFoundError
在运行时仍然遇到同样的错误。为什么?
解决方案
推荐阅读
- nativescript - 如何更改 nativescript-vue 中的 RadDataForm 样式?(Nativescript-Vue)
- laravel - Laravel 中的 Datepicker 和 chartjs(悬停时的旧图表数据)
- python - 如何摆脱烧瓶服务器代码中的全局变量?
- mysql - LEFT JOIN 不显示空值
- java - 有没有办法根据计数器创建数组列表?Java/安卓
- python - docker-compose:为什么在这里调用我的 python 应用程序?
- javascript - 从 uib-typeahead 自定义弹出窗口中检索过滤的项目不起作用
- python - 从列表中过滤结果 Python
- spring-boot - 如何在调用方法上使用resilience4j?
- c++ - 从 C++ priority_queue 解除分配