簡體   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