1. 程式人生 > >springboot中各個版本的redis配置問題

springboot中各個版本的redis配置問題

今天在springboot中使用資料庫,springboot版本為2.0.2.RELEASE,通過pom引入jar包,配置檔案application.properties中的redis配置檔案報錯,提示例如deprecated configuration property 'spring.redis.pool.max-active',猜想應該是版本不對,發現springboot在1.4前後整合redis發生了一些變化。下面截圖看下。

一、不同版本RedisProperties的區別

這是springboot版本為1.3.2RELEASE中的RedisProperties配置檔案類,從圖片中可以看得出來該本的redis配置檔案屬性有兩個內部靜態類分別是Pool和Sentinel,七個屬性變數。列入我們想在配置檔案中設定redis資料庫host地址,則可以這樣寫

spring.redis.host=localhost    host為屬性,配置連線池的最大連線數 spring.redis.pool.max-active=8

這個是redis在application.properties中springboot低版本的配置

# REDIS (RedisProperties)
# Redis資料庫索引(預設為0)
spring.redis.database=0
# Redis伺服器地址
spring.redis.host=localhost
# Redis伺服器連線埠
spring.redis.port=6379
# Redis伺服器連線密碼(預設為空)
spring.redis.password=
# 連線池最大連線數(使用負值表示沒有限制)
spring.redis.pool.max-active=8
# 連線池最大阻塞等待時間(使用負值表示沒有限制)
spring.redis.pool.max-wait=-1
# 連線池中的最大空閒連線
spring.redis.pool.max-idle=8
# 連線池中的最小空閒連線
spring.redis.pool.min-idle=0
# 連線超時時間(毫秒)
spring.redis.timeout=0

下圖則是springboot版本為2.0.2RELEASE中的RedisProperties配置檔案類,從圖中可知pool屬性則被封裝到了內部靜態類Jedis和Lettuce中去了,這時我們要是配置連線池的最大連線數,字首還是spring.redis,有兩種途徑

spring.redis.jedis.pool.max-active=8  或者 spring.redis.lettuce.pool.max-active=8

這個是redis在application.properties中springboot高版本的配置

# REDIS (RedisProperties)
# Redis資料庫索引(預設為0)
spring.redis.database=0
# Redis伺服器地址
spring.redis.host=localhost
# Redis伺服器連線埠
spring.redis.port=6379
# Redis伺服器連線密碼(預設為空)
spring.redis.password=
# 連線池最大連線數(使用負值表示沒有限制)
spring.redis.jedis.pool.max-active=8
# 連線池最大阻塞等待時間(使用負值表示沒有限制)
spring.redis.jedis.pool.max-wait=-1
# 連線池中的最大空閒連線
spring.redis.jedis.pool.max-idle=8
# 連線池中的最小空閒連線
spring.redis.jedis.pool.min-idle=0
# 連線超時時間(毫秒)
spring.redis.timeout=0

2、maven下pom中的座標配置

springboot版本1.4以下

<!--引入 spring-boot-starter-redis(1.4版本前)-->
	<dependency>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-redis</artifactId>
		<version>1.3.2.RELEASE</version>
	</dependency>

springboot版本1.4以上

<!--引入 spring-boot-starter-data-redis(1.4版本後)多了個data加個紅和粗吧-->
	<dependency>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-data-redis</artifactId>
	</dependency>
轉載請註明出處,謝謝

相關推薦

springboot各個版本redis配置問題

今天在springboot中使用資料庫,springboot版本為2.0.2.RELEASE,通過pom引入jar包,配置檔案application.properties中的redis配置檔案報錯,提示例如deprecated configuration property '

springboot數據庫配置加密

springboot 加密在springboot中,配置數據庫等信息時,用戶名和密碼明文顯示會大大降低安全性,在此介紹一種加密方式,簡單易用。添加依賴:<dependency> <groupId>com.github.ulisesbocchio</groupId>

SpringBoot多數據源配置

containe del osi object 數據 ima nag nsa eat application.properties spring.datasource.primary.driver-class-name=oracle.jdbc.driver.OracleD

springbootdruid監控的配置(DruidConfiguration)

當資料庫連線池使用druid 時,我們進行一些簡單的配置就能檢視到sql監控,web監控,url監控等等。 以springboot為例,配置如下 import com.alibaba.druid.support.http.StatViewServlet; import com.

springboot 2.x版本Redis設定JedisConnectionFactory.setHostName()過時

原文轉載:https://blog.csdn.net/Soda_lw/article/details/82661705 一、今天新建一個專案用以前的方式整合redis時,發現JedisConnectionFactory.sethostName等方法提示過時,並且RedisCacheManager

springboot使用Mybatis註解配置詳解

版權宣告:本文為博主原創文章,未經博主允許不得轉載。    https://blog.csdn.net/Winter_chen001/article/details/78623700 之前寫了關於Spring boot Mybatis 整合(註解版) 中使用了簡單的註解

SpringBoot對多個配置檔案的屬性進行提取的簡易方法

我們要提取一下屬性: 首先建立一個GirlProperties類 package com.springboot.properties; import org.springframework.boot.context.properties.ConfigurationPropertie

springbootlogback日誌常用配置,包含日誌切割

新增依賴: <!--監控--> <dependency> <groupId>org.springframework.boot</groupId>

SpringBoot使用applicationContext.xml配置檔案

SpringBoot 預設是通過Java程式碼進行依賴注入,但也為xml形式的依賴注入提供了入口,就是@ImportResource註解。我們可以在SpringBoot的啟動類上新增這個註解並在註解的locations屬性中指定xml配置檔案。(可以使用一個檔案

RabbitMq學習筆記002---RabbitMq在SpringBoot的應用_配置_使用_並且設定優先順序

首先新建一個SpringBoot的工程,空的就可以: 可以用idea 也可以用eclipse,也可以用sts,這類工具都可以 E:\StsWorkSpace\spring-boot-rabbitmq-test 然後看配置: 首先在application.properti

軟體各個版本符號的意思

一直對應用的各種版本符號代表的意思不清楚。今天理了一下專案中需要用到的各個版本的意思。主要針對下面幾個符號做說明: Alpha 版 此階段軟體逐步新增新特性,一些老特性可能被刪除。使用者嘗試使用時,不保證特性的穩定性。(這種版本也稱作內部測試版本,指開發團

maven官網各個版本代表的不同含義

tar 是什麽 .com windows系統 圖片 二進制安裝 表示 http png 現在解釋一下每個版本是什麽意思。 Binary tar.gz archive-------適用於Linux、MacOsX系統的二進制安裝工具。 Binary zip arc

springboot使用@Value讀取配置檔案

一、配置檔案配置 直接配置 在src/main/resources下新增配置檔案application.properties 例如

SpringBootSpringMVC的自動配置以及擴充套件

一、問題引入 我們在SSM中使用SpringMVC的時候,需要由我們自己寫SpringMVC的配置檔案,需要用到什麼就要自己配什麼,配置起來也特別的麻煩。我們使用SpringBoot的時候沒有進行配置,直接就能進行使用,這是為什麼呢? 這是因為SpringBoot為我們自動配置好了SpringMVC

SpringBoot 對應2.0.x版本Redis配置application.properties

properties格式: # REDIS (RedisProperties) # Redis資料庫索引(預設為0) spring.redis.database=0 # Redis伺服器地址 spring.redis.host=localhost # Redis伺服器連

springboot配置主從redis

oca 配置文件 ping bean gap ons ng- class 如果 測試redis的主從配置 redis實例 文件夾名稱如下 redis_master_s redis_slaver1_s redis_slaver2_s redis.conf文件 master

2 Springboot使用redis配置redis的key value生成策略

上一篇裡講過了redis在spring boot中的簡單使用,對於單個物件的增刪改查的預設操作。 下面來看一下在redis中,這些快取的資料是如何儲存的,為了便於後面的快取的key的可讀性,先修改一下cache的key。 @CacheConfig(cacheNames =

arcGis api for JavaScript各個版本官網下載以及在eclipse初步配置

本人最近在專案中用到arcGis,專案的技術是arcGis + JavaScript兩者相結合,經過在網上查閱資料以及請教資深人士終於成功在eclipse中載入arcGis版本的地圖,從而能夠進一步進行js的開發,由於下載以及配置花費了大量的時間,所以寫篇日誌記錄下來探索的

關於修改springbootredis配置的修改RedisTemplate 預設的序列化規則(修改成JSON資料型別)

原理:覆蓋預設配置類; 在建立的springboot專案中的啟動類中: public static void main(String[] args) { SpringApplication.run(TestspringBoot0

SpringBoot的常用配置

comm highlight tar -type cati pid 添加 maven項目 http請求 一 . 關於在application.properties文件中的一些常見配置     1.server.port=8888 :表示配置端口     2.server