I am building an application with Spring Boot using Redis (with redisson).
When I run my application in development mode, it works fine, but when I try to run it in docker containers, it fails with the error
java.lang.ClassNotFoundException:org.springframework.data.redis.connection.ReactiveStreamCommands
My maven configuration for Redis:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
<dependency>
<groupId>org.redisson</groupId>
<!-- for Spring Data Redis v.2.2.x -->
<artifactId>redisson-spring-data-22</artifactId>
<version>3.12.2</version>
</dependency>
My maven configuration to build docker container:
<plugin>
<groupId>com.spotify</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>1.2.1</version>
<dependencies>
<dependency>
<groupId>javax.activation</groupId>
<artifactId>activation</artifactId>
<version>1.1.1</version>
</dependency>
</dependencies>
<configuration>
<imageName>${imageName}</imageName>
<!-- default properties to tag an image -->
<image>${imageName}</image>
<newName>${imageName}:${tagName}</newName>
<!-- gitlab registry -->
<serverId>gitlab-repository</serverId>
<registryUrl>my.repository</registryUrl>
<baseImage>adoptopenjdk/openjdk11-openj9:latest</baseImage>
<entryPoint>["java", "-jar", "/${project.build.finalName}.jar"]</entryPoint>
<!-- copy the service's jar file from target into the root directory
of the image -->
<resources>
<resource>
<targetPath>/</targetPath>
<directory>${project.build.directory}</directory>
<include>${project.build.finalName}.jar</include>
</resource>
</resources>
</configuration>
</plugin>
When I login to my container and analysie my jar libraries (with the following command):
jar -tf my-app.jar | grep redis
I find this:
BOOT-INF/lib/spring-boot-starter-data-redis-2.1.3.RELEASE.jar
BOOT-INF/lib/spring-data-redis-2.1.5.RELEASE.jar
BOOT-INF/lib/redisson-spring-data-22-3.12.2.jar
BOOT-INF/lib/redisson-3.12.2.jar
Which is exactly the same as I get with my jar for development.
Here is the docker-compose extract on how I launch redis:
redis:
image: redis:5.0
ports:
- 6379:6379
networks:
- network
volumes:
- redis:/data
entrypoint: redis-server --appendonly yes
restart: unless-stopped
Any clue on what is missing for my container to run properly? Any idea why the spring-data-redis used in the jar is 2.1.5 and not 2.2.x? Thanks in advance
I have found a solution:
Instead of using redisson-spring-data-22
, I downgraded to redisson-spring-data-16
(as I noticed that the effective version of spring-data-redis used was in fact 2.1.5, which is lower than 2.2...).
I cannot explain why really, but it works now .
I could not find any track on redisson-spring-data of what version should be used in what conditions, so I just tried another version... and it worked!
Hope that helps.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.