测试类自动注入失败:@RunWith(SpringRunner.class)爆红详解

代码如下:

@RunWith(SpringRunner.class)
@SpringBootTest
public class ProjectFontControllerTest {

因为缺少依赖,添加此依赖问题,如果有冲突可切换版本:

   <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>
    <dependency>
		<groupId>junit</groupId>
		<artifactId>junit</artifactId>
		<version>4.12</version>
		<!--<scope>test</scope>-->
	</dependency>

版权声明:本文为ayunnuo原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。