[英]Spring boot 2.3.x + Zalando Problem + Testing
I have a spring boot 2.3.8 app working well.我有一个运行良好的 spring 启动 2.3.8 应用程序。 I used Zalando Problem object in it.
我在其中使用了 Zalando Problem object。 Now I want to write Repository test for this app, and I've got a weird error message:
现在我想为这个应用程序编写存储库测试,我收到了一条奇怪的错误消息:
UnsatisfiedDependencyException: Error creating bean with name
'org.zalando.problem.spring.web.advice.security.SecurityProblemSupport': Unsatisfied
dependency expressed through constructor parameter 0; nested exception is
org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type
'org.springframework.web.servlet.HandlerExceptionResolver' available: expected at least 1
bean which qualifies as autowire candidate. Dependency annotations:
{@org.springframework.beans.factory.annotation.Qualifier("handlerExceptionResolver")}
My test code is like this:我的测试代码是这样的:
@DataJpaTest
@AutoConfigureTestDatabase(replace = AutoConfigureTestDatabase.Replace.NONE)
@Testcontainers
class RepositoriesTest @Autowired constructor(
val siteRepository: SiteRepository,
val horseRepository: HorseRepository,
val sensorRepository: SensorRepository,
val boxRepository: BoxRepository){
companion object {
@Container
private val postgreSQLContainer = PostgreSQLContainer<Nothing>("postgres:latest")
@DynamicPropertySource
@JvmStatic
fun registerDynamicProperties(registry: DynamicPropertyRegistry) {
registry.add("spring.datasource.url", postgreSQLContainer::getJdbcUrl)
registry.add("spring.datasource.username", postgreSQLContainer::getUsername)
registry.add("spring.datasource.password", postgreSQLContainer::getPassword)
}
}
val plszName="plsz"
@Test
fun `repoTests` () {
val plsz=siteRepository.findByUrlParam(plszName)
Assertions.assertThat(plsz).isNotNull
}
}
Do I need to configure zalando problem module in test environment?测试环境需要配置zalando问题模块吗? And how?
如何? thx, Zamek
谢谢,扎梅克
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.