springboot2.0整合redis報錯

Field factory in com.xdd.xdd_commons.config.RedisTemplateConfig required a bean of type 'org.springframework.data.redis.connection.jedis.JedisConnectionFactory' that could not be found 是因爲 2.0和1.5x版本的差異問題致使 按照以前的版本配置出錯 找不到jedisConnectionFactoryhtml

<!-- Spring Boot Redis依賴 -->
        <!-- 注意:1.5版本的依賴和2.0的依賴不同,注意看哦 1.5我記得名字裏面應該沒有「data」, 2.0必須是「spring-boot-starter-data-redis」 這個才行-->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-redis
            </artifactId>
            <!-- 1.5的版本默認採用的鏈接池技術是jedis 2.0以上版本默認鏈接池是lettuce, 在這裏採用jedis,因此須要排除lettuce的jar -->
            <exclusions>
                <exclusion>
                    <groupId>redis.clients</groupId>
                    <artifactId>jedis</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>io.lettuce</groupId>
                    <artifactId>lettuce-core</artifactId>
                </exclusion>
            </exclusions>
        </dependency> <!-- 添加jedis客戶端 -->
        <dependency>
            <groupId>redis.clients</groupId>
            <artifactId>jedis</artifactId>
        </dependency>
        <!--spring2.0集成redis所需common-pool2-->
        <!-- 必須加上,jedis依賴此 -->
        <!-- spring boot 2.0 的操做手冊有標註 你們能夠去看看 地址是:https://docs.spring.io/spring-boot/docs/2.0.3.RELEASE/reference/htmlsingle/-->
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-pool2</artifactId>
            <version>2.5.0</version>
        </dependency>
        <!-- 將做爲Redis對象序列化器 -->
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>fastjson</artifactId>
            <version>1.2.54</version>
        </dependency>

原文引用地址: http://www.javashuo.com/article/p-wusfjyzh-eg.html 感謝:瘦子沒有夏天redis

相關文章
相關標籤/搜索