這是在運行測試類的時候提示報錯信息; 原因是沒有把啟動類寫好或者是沒有配置啟動類; 解決如下, 先是要正常寫好啟動類; 然后把啟動類添加到運行的測試類,添加到這個地方:@SpringBootTest; 有兩種填寫方式,一種是:@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) 還有一種是網上反饋的方法: @SpringBootTest(classes = {啟動類.class })//這里加啟動類 package com.itheima; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.junit4.SpringRunner; import com.itheima.domain.Person; @RunWith(SpringRunner.class) @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) public class ApplicationTest { @Autowired private Person person; @Test public void contextLoads() { System.out.println(person); } }