为什么我的测试类在春季启动时不被识别?



我有一个测试类,在test->java->com.example->SampleIT.java

test-config.xml存在于下面提到的位置但是,当我运行mvn clean install或mvn test时,无法识别下面的测试,因此无法运行我不知道为什么

@ContextConfiguration(locations = {"classpath:META-INF/spring/test-config.xml"})
@RunWith(SpringJunit4ClassRunner.class)
public class SampleIT{
@Autowried
private ProductServiceImpl serviceImpl;

@Test
public void test() throws Exception{
assertNotNull(serviceImpl)
}
}

下面是my pom

中的依赖项
<dependencyManagement>
<dependency>
<groupId>org.springframework.batch</groupId>
<artifactId>spring-batch-core></artifactId>
<version>4.2.4-RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.batch</groupId>
<artifactId>spring-batch-infrastructure></artifactId>
<version>4.2.4-RELEASE</version>
</dependency>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-batch></artifactId>
<dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter></artifactId>
<dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test></artifactId>
<scope>test</scope>
<dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>

无法识别,因为您在SimpleIT类的@RunWith(SpringJunit$ClassRunner.class)中拼写了$而不是4

最新更新