小编jot*_*87r的帖子

MappingMongoConverter 不可用于使用 @EnableMongoAuditing 进行单元测试的自动装配

我有一个 Spring Boot 应用程序,我在其中启用了 mongo 审核。应用程序启动正常,并存储带有所有审核字段(createdDate、updatedDate 等)的 mongo 文档。但是,在运行单元测试时,出现以下异常:

java.lang.IllegalStateException: Failed to load ApplicationContext
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mongoAuditingHandler': Cannot create inner bean '(inner bean)#115c946b' of type [org.springframework.data.mongodb.config.MongoAuditingRegistrar$MongoMappingContextLookup] while setting constructor argument; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name '(inner bean)#115c946b': Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'org.springframework.data.mongodb.core.convert.MappingMongoConverter' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}
Caused by: …
Run Code Online (Sandbox Code Playgroud)

java spring-data-mongodb spring-boot

5
推荐指数
1
解决办法
1758
查看次数

标签 统计

java ×1

spring-boot ×1

spring-data-mongodb ×1