【发布时间】:2017-06-18 11:48:36
【问题描述】:
当我启动肥皂服务应用程序时,我从控制台收到此错误
java.lang.ClassNotFoundException: org.hamcrest.Matchers
经过研究,我在pom.xml中添加了这三个依赖,启动应用时仍然存在错误
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-library</artifactId>
<version>1.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-core</artifactId>
<version>1.3</version>
<scope>test</scope>
</dependency>
感谢收到的任何帮助。
【问题讨论】:
-
使用 hamcrest-all 代替 hamcrest-library 和 hamcrest-core。
-
刚刚做了,重新启动后结果相同
-
您在项目的哪个部分使用
Matcher类?由于 pom 仅在测试范围内提供 lib,因此您只能在单元测试中使用它(/src/test/java 中的 java 文件)。