繁体   English   中英

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

[英]java.lang.ClassNotFoundException: org.hamcrest.Matchers after adding dependency too pom.xml

当我启动soap服务应用程序时,我从我的控制台收到此错误

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>

感谢收到的任何援助。

你可以尝试下面的:

<dependency>
    <groupId>org.hamcrest</groupId>
    <artifactId>hamcrest-all</artifactId>
    <version>1.3</version>        
</dependency>

此错误表示您的应用程序的类路径中没有hamcrest的lib。

如果您在运行时使用org.hamcrest.Matchers类,则必须将您的范围更改为编译或提供,如果您的midleware提供了hamcrest lib。

测试范围仅在测试生命周期中使用lib。

您可以在maven文档中阅读更多内容

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM