1.pom.xml添加依赖

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>

2.创建测试类

@SpringBootTest(classes = Demo2Application.class)
@RunWith(SpringRunner.class)
class Demo2ApplicationTests {

    @Test
    void test1() {
       
    }
}

注意:如果不行,记得将测试class包名路径改为和启动类一样的路径包名

Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐