Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running into an error after upgrading springboot from 2.3.9 to 2.6.3

After upgrading from springboot 2.3.9 to 2.6.6 I have a failing tests with the following error,

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: {}
    

One observation after upgrading,

The class ConfigFileApplicationContextInitializer from spring-boot-test jar is modified to ConfigDataApplicationContextInitializer.

like image 835
Yashwanth B Avatar asked Jan 30 '26 03:01

Yashwanth B


1 Answers

Yes, this is a legal assumption and it is the case. Actually, in spring-boot 2.4.0 ConfigFileApplicationContextInitializer was already marked as deprecated in favor ConfigDataApplicationContextInitializer. Just be aware that ConfigFileApplicationContextInitializer no longer exists in spring-boot starting from 3.0.0.
So you can just switch to ConfigDataApplicationContextInitializer and that should be enough.

like image 198
misha2048 Avatar answered Feb 01 '26 17:02

misha2048



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!