在将springboot从2.3.9升级到2.6.3后遇到错误

6za6bjd0  于 12个月前  发布在  Spring
关注(0)|答案(1)|浏览(158)

从springboot 2.3.9升级到2.6.6后,我的测试失败,出现以下错误:

java.lang.AssertionError: 
Expecting:
 <Unstarted application context org.springframework.boot.test.context.assertj.AssertableApplicationContext[startupFailure=org.springframework.beans.factory.UnsatisfiedDependencyException]>
to have a single bean of type:
 <com.air.dx.range.application.RangeApplicationService>:
but context failed to start:
 org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'IRoRangeRepository': Unsatisfied dependency expressed through method 'setDialect' parameter 0; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'org.springframework.data.relational.core.dialect.Dialect' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}

字符串
升级后的一个观察,
spring-boot-test jar中的类ConfigFileApplicationContextInitializer修改为ConfigDataApplicationContextInitializer

bnl4lu3b

bnl4lu3b1#

是的,这是一个法律的假设,事实就是如此。实际上,在spring-boot 2.4.0中,ConfigFileApplicationContextInitializerwas already marked as deprecated支持ConfigDataApplicationContextInitializer。只是要注意,从3.0.0开始,ConfigFileApplicationContextInitializer在spring-boot中不再存在。
所以你可以切换到ConfigDataApplicationContextInitializer,这应该足够了。

相关问题