[英]java.lang.ClassNotFoundException: org.hamcrest.Matchers after adding dependency too pom.xml
When I launch soap service application I get this error from my console 当我启动soap服务应用程序时,我从我的控制台收到此错误
java.lang.ClassNotFoundException: org.hamcrest.Matchers
After research, I have added these three dependencies to the pom.xml and still the error still exists on launching the application 经过研究,我已经将这三个依赖项添加到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>
Grateful for any assistance received. 感谢收到的任何援助。
Can you try with below: 你可以尝试下面的:
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-all</artifactId>
<version>1.3</version>
</dependency>
This error indicate the lib of hamcrest aren't present at classpath of your app. 此错误表示您的应用程序的类路径中没有hamcrest的lib。
If you are using the org.hamcrest.Matchers class at Runtime, is necessary to change your scope to compile or provided if your midleware provided the hamcrest lib. 如果您在运行时使用org.hamcrest.Matchers类,则必须将您的范围更改为编译或提供,如果您的midleware提供了hamcrest lib。
The test scope use the lib only in the test lifecycle. 测试范围仅在测试生命周期中使用lib。
You can read more at maven documentation 您可以在maven文档中阅读更多内容
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.