最佳答案
因为 junit:junit:4.12
将其作为传递依赖项引入。您可以通过运行看到这一点
./gradlew dependencies
这是 jUnit 文档中的相关部分
There is nothing extra that needs to be done in order to use a specific artifact of Hamcrest. In the past, there were two JUnit Maven artifacts: junit:junit and junit:junit-dep, where the latter version did not include a bundled copy of org.hamcrest:hamcrest-core and instead declared a transitive dependency on Hamcrest. In order to be more Maven-like, starting in version 4.11, there is only the junit:junit artifact which uses a transitive dependency on hamcrest-core.
关于java - 为什么 hamcrest 出现在我的类(class)路径中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39859603/