I have a spring boot 2.3.8 app working well. I used Zalando Problem object in it. 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? And how?
thx,
Zamek
question from:
https://stackoverflow.com/questions/65891126/spring-boot-2-3-x-zalando-problem-testing 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…