Cannot get connection for redisTemplate for Spring data redis

后端 未结 10 2055
太阳男子
太阳男子 2020-12-05 21:25

I\'m trying to publish a message to a channel using Spring data Redis using Jedis. Here is a very simple Java config:

@Bean(name=\"jedisConnectionFactory\")
         


        
相关标签:
10条回答
  • 2020-12-05 21:53

    Navin Viswanath, thank you for the solution! How did you find it, using docs or debugging?

    For those who use Gradle, here is my combination:

    Versions:

    • Redis 3.0.2
    • Jedis 2.7.2
    • Spring Data Redis 1.6.0 M1 (not available in maven central, because it's milestone release - add http://repo.spring.io/milestone/ repo)

    build.gradle:

    repositories {
      mavenCentral()
      maven { url 'http://repo.spring.io/release/' }
      maven { url 'http://repo.spring.io/milestone/' }
    }
    
    dependencies {
      compile group: 'redis.clients', name: 'jedis', version: '2.7.2'
      compile group: 'org.springframework.data', name: 'spring-data-redis', version: '1.6.0.M1'
    }
    

    Please note that Spring Data Redis 1.6.0.M1 will be removed once it becomes release, you need to change it to 1.6.0.RELEASE when it is available as release.

    So, I checked for version compatibility here: https://github.com/spring-projects/spring-data-redis/blob/master/gradle.properties and found related JIRA ticket here: https://jira.spring.io/browse/DATAREDIS-396

    0 讨论(0)
  • 2020-12-05 21:55

    had a similar problem with spring-boot-starter-data-redis 2.0.4

    when i implicitly put the dependency to jedis in the app pom.xml it somehow worked

        <dependency>
            <groupId>redis.clients</groupId>
            <artifactId>jedis</artifactId>
            <version>2.9.0</version>
        </dependency>
    

    eclipse complains about "Duplicating managed version", but everything else works

    0 讨论(0)
  • 2020-12-05 21:56

    Turns out I was using Jedis 2.7.2 but Spring Data Redis 1.5.0 seems to be compatible with Jedis 2.6.2. I wish this were a little clearer in the documentation somehow.

    0 讨论(0)
  • 2020-12-05 22:05

    Compatible version:

    <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-redis</artifactId>
            <version>2.0.4.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>redis.clients</groupId>
            <artifactId>jedis</artifactId>
            <version>2.9.0</version>
    </dependency>
    
    0 讨论(0)
提交回复
热议问题