我有一个带有 hibernate 功能的 SpringBoot 应用程序。在我的测试中,我想禁用任何类型的数据库连接和配置(测试无权访问数据库)。我该怎么做?
我的测试类用 @SpringBootTest
注释并有 @Autowired
特性。
禁用所有数据库交互的正确注释值是什么?
@SpringBootTest
class MyTest {
@Autowired
....
}
最佳答案
您可以使用 @TestPropertySource
覆盖 application.properties
中的值.
@TestPropertySource(locations="classpath:test.properties")
A Quick Guide to @TestPropertySource
关于hibernate - 使用@SpringBootTest 禁用数据库连接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58517307/