企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
**1.依赖管理** ~~~ <!-- spring整合junit测试 --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> <exclusions> <exclusion> <groupId>org.junit.vintage</groupId> <artifactId>junit-vintage-engine</artifactId> </exclusion> </exclusions> </dependency> ~~~ **2.项目运行** //创建spring容器 //classes 指定引导类 @SpringBootTest(classes = SpringbootMybatisApplication.class) **3.测试代码** ~~~ import com.nobb.SpringBootDemo; import com.nobb.service.User; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; @SpringBootTest(classes = SpringBootDemo.class) public class MyTest { @Autowired private User user; @Test public void fun1(){ System.out.println(user.test()); } } ~~~