简体   繁体   English

java.lang.ClassNotFoundException:org.hamcrest.Matchers后添加依赖项pom.xml

[英]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.

相关问题 引起原因:java.lang.ClassNotFoundException:org.apache.commons.io.FileUtils,maven pom.xml wa - Caused by: java.lang.ClassNotFoundException: org.apache.commons.io.FileUtils, maven pom.xml wa 尽管添加了依赖项,但java.lang.ClassNotFoundException - java.lang.ClassNotFoundException inspite of adding dependency java.lang.NoClassDefFoundError: org/hamcrest/Matchers - java.lang.NoClassDefFoundError: org/hamcrest/Matchers Java - 在 pom.xml 中添加 jar 依赖 - Java - Adding jar dependency in pom.xml 无法在测试文件中导入org.hamcrest.Matchers - Can't import org.hamcrest.Matchers in test files org.hamcrest.Matchers用于同时匹配Object的不同属性 - org.hamcrest.Matchers for matching different properties simultaneously of an Object java.lang.module.ResolutionException 添加 tess4j 依赖到 pom.xml - java.lang.module.ResolutionException when adding tess4j dependency to pom.xml 添加Maven依赖导致java.lang.ClassNotFoundException - adding maven dependency causing java.lang.ClassNotFoundException 线程“main”中的异常 java.lang.NoClassDefFoundError: org/hamcrest/Matchers - Exception in thread "main" java.lang.NoClassDefFoundError: org/hamcrest/Matchers java.lang.ClassNotFoundException:org.sonar.java.model.JavaTree“创建声纳插件的依赖性问题” - java.lang.ClassNotFoundException: org.sonar.java.model.JavaTree “dependency issue creating a sonar plugin”
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM