我只是将MongoDB配置添加到现有的Sping Boot 应用程序中,一些测试类具有@SpringBootTest
注解,这些类抛出异常,表明我需要定义嵌入式MongoDB版本,如下所示...Set the spring.mongodb.embedded.version property...
我在test/resources/application.properties
上将此设置为4.4版本。
现在它开始抛出下面的异常
[org/springframework/boot/autoconfigure/data/mongo/MongoDatabaseFactoryDependentConfiguration.class]: Unsatisfied dependency expressed through method 'mongoTemplate' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'mongoDatabaseFactory' defined in class path resource
[org/springframework/boot/autoconfigure/data/mongo/MongoDatabaseFactoryConfiguration.class]: Unsatisfied dependency expressed through method 'mongoDatabaseFactory' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'embeddedMongoServer' defined in class path resource
[org/springframework/boot/autoconfigure/mongo/embedded/EmbeddedMongoAutoConfiguration.class]: Unsatisfied dependency expressed through method 'embeddedMongoServer' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'embeddedMongoConfiguration' defined in class path resource
[org/springframework/boot/autoconfigure/mongo/embedded/EmbeddedMongoAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [de.flapdoodle.embed.mongo.config.MongodConfig]: Factory method 'embeddedMongoConfiguration' threw exception; nested exception is java.lang.ArrayIndexOutOfBoundsException: Index 2 out of bounds for length 2
使用Sping Boot 2.7.10如何使其与@SpringBootTest annotation一起工作?
1条答案
按热度按时间monwx1rj1#
它使用这些属性,从4.4降级embedded-mongo并提供完整的uri