Spring 4 with Elasticsearch 5 - java

Is it possible to use elasticsearch server version 5 in combination with spring 4 (spring-data-elasticsearch)?
So far if I use spring-data-elasticsearch 2.x, I can load the app, but get error failed to get local cluster state.
If I include 3.x then I cannot start the app with error Initialization of bean failed; nested exception is java.lang.AbstractMethodError...
I suceeded to connect using spring boot 2.x, but this one uses all spring libraries >5 which is currently not an option for me.

For Elasticsearch 5.x you need to use Spring Data 3.x (Kay). Spring Boot 2.x uses that version, so that should work as you described it.
Taking a look at spring-data-parent there is an explicit dependency on Spring 5.x, so I don't think using Spring 4 will work; at least not without a lot of dependency wrangling. IMO the way forward will be to get to Spring 5 and then use Spring Data 3.

Related

Spring Cloud Sleuth with Spring Boot 3.0 and Tracer

I use spring sleuth in my project and after I updated spring-boot to version 3 I receive the following error:
Consider defining a bean of type 'org.springframework.cloud.sleuth.Tracer' in your configuration.
I inject Tracer in my logging service to get current traceId and spanId. This is the dependency for spring sleuth:
implementation 'org.springframework.cloud:spring-cloud-starter-sleuth:3.1.5'
Is Tracer Bean no longer built in in terms of spring boot v3?
Spring Cloud Sleuth’s last minor version is 3.1. You can check the 3.1.x branch for the latest commits. The core of this project got moved to Micrometer Tracing project and the instrumentations will be moved to Micrometer and all respective projects (no longer all instrumentations will be done in a single repository).
see: https://spring.io/projects/spring-cloud-sleuth
This means that for Boot 3.x you need to use Micrometer Tracing instead of Sleuth.

Spring boot 2.2.4 release is not compatible with azure spring data cosmos 3.x.x

I'm working on springboot with cosmos api,So if i use #Query that is provided by azure-spring-data-cosmos library(3.x.x) with Springboot 2.5.0 able to get the results from cosmos database. But if i use the same azure-spring-data-cosmos library(3.x.x) with springboot 2.2.4 getting below exception
Field userRepository in com.example.service.UserService required a bean of type 'com.example.repository.UserRepository' that could not be found.The injection point has the following annotations:
- #org.springframework.beans.factory.annotation.Autowired(required=true)
Action:Consider defining a bean of type 'com.example.repository.UserRepository' in your configuration.
I would highly recommend using the latest azure-spring-data-cosmos SDK version 3.19.0 - https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/cosmos/azure-spring-data-cosmos/CHANGELOG.md#3190-2022-03-10
Since spring boot releases one major version every 6 months, azure spring team supports last 2 versions of Spring Boot. We currently support spring boot 2.5.x and 2.6.x. You should be able to use any one of these versions of spring-boot with latest version of azure-spring-data-cosmos SDK.
The changelog points to the compatible version of spring boot which can be used with azure-spring-data-cosmos SDK.
Also, spring-boot 2.2.4 is more than 2 years old at this point of time. We don't support it anymore.
Not sure which version of cosmos you are using but cosmos change log clearly mentions that 3.5.0 has spring boot support 2.4.3 & above.
Please check if your cosmos version is 3.5.0 which might be causing this issue.
Reference link :
https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/cosmos/azure-spring-data-cosmos/CHANGELOG.md#350-2021-03-11

Is spring-data-redis compatible with Spring 3?

I have been looking all over the internet on how to configure Spring MVC 3 with redis but all in vain. I want to connect to redis using Spring MVC 3.
I have worked with spring boot and spring-data-redis and everything is working fine. I can connect to redis and store sessions. But the project I am currently working on is legacy based. It uses spring 3 but I believe spring-data-redis is compatible with spring 4 and above. Are there any alternates to make connection between spring 3 and redis. Any tutorial would be helpful.
I expect to store session data like username in the redis using Spring MVC 3
Well, from the documentation of the oldiest available spring-data-redis release
it looks like the minimal 2.x version is indeed spring 4
However, Spring data redis 1.x should work with spring 3.x:
https://docs.spring.io/spring-data/redis/docs/1.4.0.M1/reference/htmlsingle/#why-spring-redis
Having said that I haven't tried it by myself and if you're only storing sessions in redis, maybe using spring data is an overkill.
After all you can create a Jedis plugin by yourself, expose it as a bean and call the commands directly via the jedis driver. Its also possible to go with reactive client...

Foreseeing issues when upgrading from Spring 4.2 to Spring 5.0.5

On my current project we are using Spring 4.2 (core, aop, beans, web , webmvc, etc).
What are the major problems we could encounter when upgrading from Spring 4.2 to Spring 5.0.5? How backward compatible would Spring Security 4.2 be with Spring 5.0.5?
Thank you for your time.
It's hard to tell without knowing which functionalities and features of Spring your project relies on.
I'd suggest to start by reviewing official changelogs and release notes to determine the affected parts of your project.
What's New in Spring Framework 5.x might be a good starting point.
Especially watch out for removed features and APIs.
There also is a Spring Integration 4.3 to 5.0 Migration Guide.
while upgrading to Spring 4.2.7 i faced below two issues
Get and Delete requests containing ";" and "%" character will fail with 500 response because of the HttpFirewall restrictions. You can refer to below link for solution.
Getting 500 response in Spring 5 when url contains semicolon
Spring 5 needs default password encoder otherwise it will throw below exception
java.lang.IllegalArgumentException: There is no PasswordEncoder mapped for the id "null
You can refer to below link for solution.
Spring Security 5 : There is no PasswordEncoder mapped for the id "null"

Spring boot + cassandra 3.x

Is the way to use cassandra 3.x with Spring boot?
I was trying to use new version of spring-data-cassandra 1.5.0 while cassandra driver 3.0 is supported, but Spring boot change the dependency to 2.1.9.
I also tried to use spring-data-cassandra 1.5.0 without Spring boot, but there is not a reference documentation i i have got some errors.
I've spent whole day for trying to make it works, but there are no effects.
Maybe someone have some samples or information that can help me to run cassandra cluster on Spring boot :)

Categories

Resources