1、引入依赖
<dependency> <groupId>org.junit.jupiter</groupId> <artifactId>junit-jupiter-api</artifactId> <version>5.9.1</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-test</artifactId> <version>6.0.2</version> </dependency>
2、配置类
@ComponentScan("com.jixian") @Configuration public class SpringConfig { }
3、测试
@Component public class User { private Integer uid; private String uname; public void test(){ System.out.println("user...."); } }
@SpringJUnitConfig(classes = SpringConfig.class) public class TestUser { @Autowired private User user; @Test public void test01(){ System.out.println(user); user.test(); } }
标签:System,private,public,user,整合,test,Junit5,class From: https://www.cnblogs.com/jixian/p/17161508.html