+-

当我试图导入 import org.junit.Test我面对的是 The import org.junit.Test conflicts with a type defined in the same file 错误。我可以导入 Before 和 After 没有任何问题。当使用 @Test 注解,Eclipse 无法识别它,所以不让我以这种方式导入。
导入。
import org.junit.Before;
import org.junit.After;
import org.junit.Test;
Maven依赖性。
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
8
投票
投票
你能不能确保类文件名不在同一个文件中?Test? 所以... 将测试类改名为其他 名字应该可以。最好的做法是用 "Test "这个词来结束测试类,比如MyServiceTest。类似的问题前段时间也发过 此处.