从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。
1条答案
按热度按时间bnl4lu3b1#
是的,这是一个法律的假设,事实就是如此。实际上,在spring-boot 2.4.0中,
ConfigFileApplicationContextInitializer
was already marked as deprecated支持ConfigDataApplicationContextInitializer
。只是要注意,从3.0.0开始,ConfigFileApplicationContextInitializer
在spring-boot中不再存在。所以你可以切换到
ConfigDataApplicationContextInitializer
,这应该足够了。