<dependencies> <!-- Spring Test --> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-test</artifactId> <version>5.3.10</version> <scope>test</scope> </dependency> <!-- JUnit --> <dependency> <groupId>org.junit.jupiter</groupId> <artifactId>junit-jupiter-api</artifactId> <version>5.8.1</version> <scope>test</scope> </dependency> </dependencies> @Configuration @ComponentScan("com.example") public class AppConfig { } @ExtendWith(SpringExtension.class) @ContextConfiguration(classes = AppConfig.class) public class MyServiceTest { @Autowired private MyService myService; @Test public void testMethod() { } }


上一篇:
下一篇:
切换中文