【发布时间】:2020-05-12 03:41:13
【问题描述】:
我在我的 Spring Boot 测试文件中使用了以下注释
@RunWith(SpringRunner.class) // tells JUnit to run using Spring’s testing support.
@SpringBootTest // is saying “bootstrap with Spring Boot’s support” (e.g. load application.properties and give me all the Spring Boot goodness)
@AutoConfigureMockMvc
当我测试休息控制器时,它会显示java.lang.IllegalStateException: Failed to load ApplicationContext。
我检查了日志,这是由 JMS 和数据库的连接问题引起的。对于我的休息控制器测试,我不需要它们中的任何一个。但是它们的配置是在 application.properties 文件中定义的,并且会在 SpringBootTest 中加载,如何使用不同的 application.properties 文件进行测试?
【问题讨论】:
-
使用@ActiveProfiles baeldung.com/spring-profiles
标签: java spring-boot junit spring-boot-test