我在 4.10 使用 junit 并在 1.3 声明 hamcrest-core,在 1.3 声明 hamcrest-library。我的问题是嵌入在 junit 4.10 中的 hamcrest-library 和 hamcrest-core。 junit 4.11 怎么样?
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.10</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-library</artifactId>
<version>1.3</version>
<scope>test</scope>
</dependency>
最佳答案
如果您浏览到 search.maven.org您可以搜索 Artifact 并查看它们的依赖项。如果您使用带有 Maven 插件的 Eclipse,您还可以在 POM 编辑器中单击 Dependency Hierarchy。
看着Maven website你可以看到 JUnit 4.11 依赖于 Hamcrest 1.3:
<dependencies>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-core</artifactId>
<version>1.3</version>
<scope>compile</scope>
</dependency>
</dependencies>
您必须自己添加 Hamcrest 库。
关于maven - junit 和 hamcrest 声明,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15660807/