原因:Maven依赖有一个<scope>,因为JUnit是直接添加到路径中,并不是通过Maven依赖加入,如果加入了<scope>会导致匹配不上
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<scope>test</scope>
</dependency>
解决方式:因为在Maven依赖中多了<scope>标签,所以删除之后即可
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>