Upgrading spring-boot version to 2.7.5, migrating to springdoc - java

While upgrading my spring-boot project to 2.7.5 i got some incompaitability issues with springfox and actuator, for that i made changes by following this link...
Spring Boot 2.6.0 / Spring fox 3 - Failed to start bean 'documentationPluginsBootstrapper'
Im using Actuator in my project, with the above changes actuator endpoints like /health not working fine, so i decided to migrate to springdoc.. i made the changes but im unable to open my swagger.. getting the below error
java.lang.IllegalStateException: Failed to load ApplicationContext
Caused by: org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'requestMappingHandlerMapping' defined
in class path resource
[org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration$EnableWebMvcConfiguration.class]
I have added spring.mvc.pathmatch.matching-strategy=ant_path_matcher, im not getting the error but swagger was not opening and the actuator endpoints also not working as expected getting status as DOWN while checking the health..

Related

DAO test case getting failed

DAO test cases getting failed due to below error:
Caused by: java.lang.ClassNotFoundException: de.flapdoodle.embed.process.config.RuntimeConfig
we are using spring boot 2.7.3 version , Spring data mongoDB :3.4.2, MongoDB :4.2,
de.flaodoodle.embeded.mongo-2.2.0, de.flaodoodle.embeded.process-2.1.2
Please help for the same
Try adding this to your spring boot application:
#SpringBootApplication(exclude = EmbeddedMongoAutoConfiguration.class)
It will disable auto configuration as that causes issues. You can use your own configuration in this case.

Upgrading Springboot to 2.5.12 Causing build failure while Overriding Mock Cassandra

I have a springboot application which uses Cassandra Connection.Also my testClasses has mocked Cassandra Connection.
The following mocks worked till i was using Sprinboot 2.3.3.Release CqlSession,CqlSessionFactoryBean,CassandraProperties,InterfaceRepos,CassandraConverter,DriverContextCodecRegistryCassandraMappingContextReactiveCassandraTemplate
Now I am trying to upgrade Springboot application
from 2.3.3.Release to 2.5.12,
The following are upgraded because of springboot upgrade
Springjars upgraded from 5.2.8.Release to 5.3.18,
Spring-data-Cassandra from 3.0.3.Release to 3.2.10
java-driver-core from 4.6.1 to 4.11.3
com.datastax.cassandra:cassandra-driver-core:jar is still 3.11.0
My main application is able to connect with cassandra without issues, whereas my testCases fails while overriding the Cassandra Connection.Now when i run my testCases, it fails with the below error:
Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException:
Failed to instantiate [org.springframework.data.cassandra.ReactiveSession]: Factory method 'reactiveCassandraSession' threw exception;
nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.datastax.oss.driver.api.core.CqlSession' available
Troubleshooting measure i did:
i)After i upgrade spring boot 2.5.12 , if i downgrade spring-context-5.3.18.Release to 5.2.8.Release i am able to run test cases without issues , so even when i increment to 5.2.9.Release i am getting the above issue , but i believe downgrading to spring-context:5.2.8 is not a good solution.
ii)I have downgraded Spring-data-Cassandra & java-driver-core with different combinations but it didn't provide any fix.
iii)I tried replacing #Mock annotations with mock()

When I add Actuator dependency it gives UnsatisfiedDependencyException

I have a springboot application. When I add spring-boot-starter-actuator dependency to my pom it gives UnsatisfiedDependencyException.
Without this dependency, application is running. When I put it, application not running.
Can anyone provide a solution for this?
Error:
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'servoMetricCollector' defined in class path resource

initializing AWS with Springboot

I am trying to initialize and build a Springboot Application that uses AWS dependencies on Net Beans, however, I am having a problem building the project. After resolving the errors after creating the project I am getting an error when I try to build. The message I get is
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.cloud.aws.context.support.io.ResourceLoaderBeanPostProcessor#0': Cannot resolve reference to bean 'amazonS3' while setting constructor argument;
I found some previous answers saying to put cloud.aws.stack.auto=false in my application.properties file, however, I seem to be getting the same problem after I clean and build again.
If you are building/ testing or running locally (as opposed to EC2) then you need to have a region property such as in application.properties assuming you use the default profile for build and test.
cloud.aws.region.static=us-east-1

All beans fail autowire on startup because of a NoSuchMethodError

After upgrading my project to Spring AOP 4.3.7 I get this error trace on every bean auto-wire at Spring Boot startup:
Caused by: java.lang.NoSuchMethodError: org.springframework.aop.framework.AopProxyUtils.getSingletonTarget(Ljava/lang/Object;)Ljava/lang/Object;
at org.springframework.context.event.AbstractApplicationEventMulticaster.addApplicationListener(AbstractApplicationEventMulticaster.java:105)
at org.springframework.context.support.AbstractApplicationContext.addApplicationListener(AbstractApplicationContext.java:494)
at org.springframework.context.support.ApplicationListenerDetector.postProcessAfterInitialization(ApplicationListenerDetector.java:78)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsAfterInitialization(AbstractAutowireCapableBeanFactory.java:423)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1633)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:555)
...Stack truncated here for privacy reasons...
I get the sense this is a mismatch in a Spring AOP Jar somewhere in the stack, but cannot find anything that references an actual object to trace.
I was able to resolve this by upgrading to Spring AOP 4.3.13
See these links for the old and new versions of these libraries in the API.

Categories