java - 包 org.hamcrest 不存在
问题描述
我得到了错误java: package org.hamcrest does not exist
。POM 文件如下所示:
<dependencies>
...
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-all</artifactId>
<version>1.3</version>
<scope>test</scope>
</dependency>
</dependencies>
在一些测试中,我有这个导致错误的导入:
import static org.hamcrest.CoreMatchers.*;
我正在使用 IntelliJ 2017.3.4
我尝试删除scope
标签并将其更改为compile
,并导入其他hamcrest
包,如hamcrest.core
. 此外,运行mvn clean
和重建项目也不起作用。
解决方案
手动删除.idea
文件夹并重建工作。