diff --git a/pom.xml b/pom.xml
index 93b42579..077f8f13 100644
--- a/pom.xml
+++ b/pom.xml
@@ -46,6 +46,7 @@
UTF-8
MMddHHmm
3.1.1
+ 3.1.0
5.2.0
@@ -80,6 +81,12 @@
spring-boot-starter-security
+
+ redis.clients
+ jedis
+ ${jedis-version}
+
+
com.alibaba
diff --git a/sql/mysql.sql b/sql/mysql.sql
index 0bb4c03a..5d8bbfc8 100644
--- a/sql/mysql.sql
+++ b/sql/mysql.sql
@@ -1,112 +1,145 @@
-- auto-generated definition
-create schema wvp collate utf8_bin;
+
+
+CREATE DATABASE `wvp` /*!40100 DEFAULT CHARACTER SET utf8mb3 COLLATE utf8mb3_bin */;
+
+use wvp;
create table device
(
- deviceId varchar(50) not null
+ deviceId varchar(50) not null
primary key,
- name varchar(255) null,
- manufacturer varchar(255) null,
- model varchar(255) null,
- firmware varchar(255) null,
- transport varchar(50) null,
- streamMode varchar(50) null,
- online varchar(50) null,
- registerTime varchar(50) null,
- keepaliveTime varchar(50) null,
- ip varchar(50) not null,
- createTime varchar(50) not null,
- updateTime varchar(50) not null,
- port int not null,
- expires int not null,
- hostAddress varchar(50) not null
+ name varchar(255) null,
+ manufacturer varchar(255) null,
+ model varchar(255) null,
+ firmware varchar(255) null,
+ transport varchar(50) null,
+ streamMode varchar(50) null,
+ online varchar(50) null,
+ registerTime varchar(50) null,
+ keepaliveTime varchar(50) null,
+ ip varchar(50) not null,
+ createTime varchar(50) not null,
+ updateTime varchar(50) not null,
+ port int not null,
+ expires int not null,
+ hostAddress varchar(50) not null
);
create table device_channel
(
- channelId varchar(50) not null,
+ channelId varchar(50) not null,
name varchar(255) null,
- manufacture varchar(50) null,
- model varchar(50) null,
- owner varchar(50) null,
- civilCode varchar(50) null,
- block varchar(50) null,
- address varchar(50) null,
- parentId varchar(50) null,
+ manufacture varchar(50) null,
+ model varchar(50) null,
+ owner varchar(50) null,
+ civilCode varchar(50) null,
+ block varchar(50) null,
+ address varchar(50) null,
+ parentId varchar(50) null,
safetyWay int null,
registerWay int null,
- certNum varchar(50) null,
+ certNum varchar(50) null,
certifiable int null,
errCode int null,
- endTime varchar(50) null,
- secrecy varchar(50) null,
- ipAddress varchar(50) null,
+ endTime varchar(50) null,
+ secrecy varchar(50) null,
+ ipAddress varchar(50) null,
port int null,
password varchar(255) null,
PTZType int null,
status int null,
longitude double null,
latitude double null,
- streamId varchar(50) null,
- deviceId varchar(50) not null,
- parental varchar(50) null,
- hasAudio bit(1) null,
- createTime varchar(50) not null,
- updateTime varchar(50) not null,
+ streamId varchar(50) null,
+ deviceId varchar(50) not null,
+ parental varchar(50) null,
+ hasAudio bit null,
+ createTime varchar(50) not null,
+ updateTime varchar(50) not null,
primary key (channelId, deviceId)
);
create table device_mobile_position
(
- deviceId varchar(50) not null,
+ deviceId varchar(50) not null,
deviceName varchar(255) null,
- time varchar(50) not null,
+ time varchar(50) not null,
longitude double not null,
latitude double not null,
altitude double null,
speed double null,
direction double null,
- reportSource varchar(50) null,
- geodeticSystem varchar(50) null,
- cnLng varchar(50) null,
- cnLat varchar(50) null,
+ reportSource varchar(50) null,
+ geodeticSystem varchar(50) null,
+ cnLng varchar(50) null,
+ cnLat varchar(50) null,
primary key (deviceId, time)
);
create table gb_stream
(
- app varchar(255) not null,
- stream varchar(255) not null,
- gbId varchar(50) not null,
- name varchar(255) null,
- longitude double null,
- latitude double null,
- streamType varchar(50) null,
- status int null,
+ app varchar(255) not null,
+ stream varchar(255) not null,
+ gbId varchar(50) not null,
+ name varchar(255) null,
+ longitude double null,
+ latitude double null,
+ streamType varchar(50) null,
+ mediaServerId varchar(50) null,
+ status int null,
primary key (app, stream, gbId)
);
+create table media_server
+(
+ id varchar(255) not null
+ primary key,
+ ip varchar(50) not null,
+ hookIp varchar(50) not null,
+ sdpIp varchar(50) not null,
+ streamIp varchar(50) not null,
+ httpPort int not null,
+ httpSSlPort int not null,
+ rtmpPort int not null,
+ rtmpSSlPort int not null,
+ rtpProxyPort int not null,
+ rtspPort int not null,
+ rtspSSLPort int not null,
+ autoConfig int not null,
+ secret varchar(50) not null,
+ streamNoneReaderDelayMS int not null,
+ rtpEnable int not null,
+ rtpPortRange varchar(50) not null,
+ recordAssistPort int not null,
+ defaultServer int not null,
+ createTime varchar(50) not null,
+ updateTime varchar(50) not null,
+ constraint media_server_i
+ unique (ip, httpPort)
+);
+
create table parent_platform
(
- id int auto_increment,
+ id int auto_increment,
enable int null,
name varchar(255) null,
- serverGBId varchar(50) not null,
- serverGBDomain varchar(50) null,
- serverIP varchar(50) null,
+ serverGBId varchar(50) not null,
+ serverGBDomain varchar(50) null,
+ serverIP varchar(50) null,
serverPort int null,
- deviceGBId varchar(50) not null,
- deviceIp varchar(50) null,
- devicePort varchar(50) null,
+ deviceGBId varchar(50) not null,
+ deviceIp varchar(50) null,
+ devicePort varchar(50) null,
username varchar(255) null,
- password varchar(50) null,
- expires varchar(50) null,
- keepTimeout varchar(50) null,
- transport varchar(50) null,
- characterSet varchar(50) null,
+ password varchar(50) null,
+ expires varchar(50) null,
+ keepTimeout varchar(50) null,
+ transport varchar(50) null,
+ characterSet varchar(50) null,
ptz int null,
rtcp int null,
- status bit(1) null,
+ status bit null,
primary key (id, serverGBId)
);
@@ -121,7 +154,7 @@ create table platform_gb_channel
create table platform_gb_stream
(
- platformId varchar(50) not null,
+ platformId varchar(50) not null,
app varchar(255) not null,
stream varchar(255) not null,
primary key (platformId, app, stream)
@@ -129,7 +162,7 @@ create table platform_gb_stream
create table stream_proxy
(
- type varchar(50) not null,
+ type varchar(50) not null,
app varchar(255) not null,
stream varchar(255) not null,
url varchar(255) null,
@@ -137,11 +170,12 @@ create table stream_proxy
dst_url varchar(255) null,
timeout_ms int null,
ffmpeg_cmd_key varchar(255) null,
- rtp_type varchar(50) null,
- mediaServerId varchar(50) null,
- enable_hls bit(1) null,
- enable_mp4 bit(1) null,
- enable bit(1) not null,
+ rtp_type varchar(50) null,
+ mediaServerId varchar(50) null,
+ enable_hls bit null,
+ enable_mp4 bit null,
+ enable bit not null,
+ createTime varchar(50) not null,
primary key (app, stream)
);
@@ -149,11 +183,12 @@ create table stream_push
(
app varchar(255) not null,
stream varchar(255) not null,
- totalReaderCount varchar(50) null,
+ totalReaderCount varchar(50) null,
originType int null,
- originTypeStr varchar(50) null,
+ originTypeStr varchar(50) null,
createStamp int null,
aliveSecond int null,
+ mediaServerId varchar(50) null,
primary key (app, stream)
);
@@ -164,31 +199,6 @@ create table user
username varchar(255) not null,
password varchar(255) not null,
roleId int not null,
- create_time varchar(50) not null
+ create_time varchar(50) not null
);
-insert into user (username, password, roleId, create_time) values ('admin', '21232f297a57a5a743894a0e4a801fc3', '0', '2021-04-13 14:14:57');
-
-create table media_server (
- id varchar(255)
- primary key,
- ip varchar(50) NOT NULL,
- hookIp varchar(50) NOT NULL,
- sdpIp varchar(50) NOT NULL,
- streamIp varchar(50) NOT NULL,
- httpPort int NOT NULL,
- httpSSlPort int NOT NULL,
- rtmpPort int NOT NULL,
- rtmpSSlPort int NOT NULL,
- rtpProxyPort int NOT NULL,
- rtspPort int NOT NULL,
- rtspSSLPort int NOT NULL,
- autoConfig int NOT NULL,
- secret varchar(50) NOT NULL,
- streamNoneReaderDelayMS int NOT NULL,
- rtpEnable int NOT NULL,
- rtpPortRange varchar(50) NOT NULL,
- recordAssistPort int NOT NULL,
- createTime varchar(50) not null,
- updateTime varchar(50) not null
-);
\ No newline at end of file
diff --git a/src/main/java/com/genersoft/iot/vmp/common/VideoManagerConstants.java b/src/main/java/com/genersoft/iot/vmp/common/VideoManagerConstants.java
index 57493143..cb2b1732 100644
--- a/src/main/java/com/genersoft/iot/vmp/common/VideoManagerConstants.java
+++ b/src/main/java/com/genersoft/iot/vmp/common/VideoManagerConstants.java
@@ -12,6 +12,8 @@ public class VideoManagerConstants {
public static final String MEDIA_SERVER_PREFIX = "VMP_MEDIA_SERVER_";
+ public static final String MEDIA_SERVERS_ONLINE_PREFIX = "VMP_MEDIA_ONLINE_SERVERS";
+
public static final String MEDIA_STREAM_PREFIX = "VMP_MEDIA_STREAM";
public static final String DEVICE_PREFIX = "VMP_DEVICE_";
@@ -45,4 +47,8 @@ public class VideoManagerConstants {
public static final String EVENT_OUTLINE_UNREGISTER = "1";
public static final String EVENT_OUTLINE_TIMEOUT = "2";
+
+ public static final String MEDIA_SSRC_USED_PREFIX = "VMP_media_used_ssrc_";
+
+ public static final String MEDIA_TRANSACTION_USED_PREFIX = "VMP_media_transaction_";
}
diff --git a/src/main/java/com/genersoft/iot/vmp/conf/MediaConfig.java b/src/main/java/com/genersoft/iot/vmp/conf/MediaConfig.java
index f2a0bcd0..744e56f0 100644
--- a/src/main/java/com/genersoft/iot/vmp/conf/MediaConfig.java
+++ b/src/main/java/com/genersoft/iot/vmp/conf/MediaConfig.java
@@ -1,13 +1,16 @@
package com.genersoft.iot.vmp.conf;
-import com.genersoft.iot.vmp.media.zlm.dto.IMediaServerItem;
+import com.genersoft.iot.vmp.gb28181.session.SsrcConfig;
import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.util.StringUtils;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
@Configuration("mediaConfig")
-public class MediaConfig implements IMediaServerItem {
+public class MediaConfig{
@Value("${media.id:}")
private String id;
@@ -21,6 +24,9 @@ public class MediaConfig implements IMediaServerItem {
@Value("${sip.ip}")
private String sipIp;
+ @Value("${sip.domain}")
+ private String sipDomain;
+
@Value("${media.sdp-ip:${media.ip}}")
private String sdpIp;
@@ -66,31 +72,14 @@ public class MediaConfig implements IMediaServerItem {
@Value("${media.record-assist-port:0}")
private Integer recordAssistPort = 0;
- private String updateTime;
-
- private String createTime;
-
- private boolean docker = false;
-
- private int count;
-
-
public String getId() {
return id;
}
- public void setId(String id) {
- this.id = id;
- }
-
public String getIp() {
return ip;
}
- public void setIp(String ip) {
- this.ip = ip;
- }
-
public String getHookIp() {
if (StringUtils.isEmpty(hookIp)){
return sipIp;
@@ -100,78 +89,26 @@ public class MediaConfig implements IMediaServerItem {
}
- public void setHookIp(String hookIp) {
- this.hookIp = hookIp;
- }
-
public String getSipIp() {
return sipIp;
}
- public void setSipIp(String sipIp) {
- this.sipIp = sipIp;
- }
-
- public void setSdpIp(String sdpIp) {
- this.sdpIp = sdpIp;
- }
-
- public void setStreamIp(String streamIp) {
- this.streamIp = streamIp;
- }
-
public int getHttpPort() {
return httpPort;
}
- @Override
- public void setHttpPort(int httpPort) {
-
- }
-
- public void setHttpPort(Integer httpPort) {
- this.httpPort = httpPort;
- }
-
public int getHttpSSlPort() {
return httpSSlPort;
}
- @Override
- public void setHttpSSlPort(int httpSSlPort) {
-
- }
-
- public void setHttpSSlPort(Integer httpSSlPort) {
- this.httpSSlPort = httpSSlPort;
- }
-
public int getRtmpPort() {
return rtmpPort;
}
-
- @Override
- public void setRtmpPort(int rtmpPort) {
-
- }
-
- public void setRtmpPort(Integer rtmpPort) {
- this.rtmpPort = rtmpPort;
- }
-
+
public int getRtmpSSlPort() {
return rtmpSSlPort;
}
- @Override
- public void setRtmpSSlPort(int rtmpSSlPort) {
-
- }
-
- public void setRtmpSSlPort(Integer rtmpSSlPort) {
- this.rtmpSSlPort = rtmpSSlPort;
- }
-
public int getRtpProxyPort() {
if (rtpProxyPort == null) {
return 0;
@@ -181,104 +118,38 @@ public class MediaConfig implements IMediaServerItem {
}
- @Override
- public void setRtpProxyPort(int rtpProxyPort) {
-
- }
-
- public void setRtpProxyPort(Integer rtpProxyPort) {
- this.rtpProxyPort = rtpProxyPort;
- }
-
public int getRtspPort() {
return rtspPort;
}
- @Override
- public void setRtspPort(int rtspPort) {
-
- }
-
- public void setRtspPort(Integer rtspPort) {
- this.rtspPort = rtspPort;
- }
-
public int getRtspSSLPort() {
return rtspSSLPort;
}
- @Override
- public void setRtspSSLPort(int rtspSSLPort) {
-
- }
-
- public void setRtspSSLPort(Integer rtspSSLPort) {
- this.rtspSSLPort = rtspSSLPort;
- }
-
public boolean isAutoConfig() {
return autoConfig;
}
- public void setAutoConfig(boolean autoConfig) {
- this.autoConfig = autoConfig;
- }
-
public String getSecret() {
return secret;
}
- public void setSecret(String secret) {
- this.secret = secret;
- }
-
public String getStreamNoneReaderDelayMS() {
return streamNoneReaderDelayMS;
}
- public void setStreamNoneReaderDelayMS(String streamNoneReaderDelayMS) {
- this.streamNoneReaderDelayMS = streamNoneReaderDelayMS;
- }
-
public boolean isRtpEnable() {
return rtpEnable;
}
- public void setRtpEnable(boolean rtpEnable) {
- this.rtpEnable = rtpEnable;
- }
-
public String getRtpPortRange() {
return rtpPortRange;
}
-
- public void setRtpPortRange(String rtpPortRange) {
- this.rtpPortRange = rtpPortRange;
- }
-
+
public int getRecordAssistPort() {
return recordAssistPort;
}
- @Override
- public void setRecordAssistPort(int recordAssistPort) {
-
- }
-
- public void setRecordAssistPort(Integer recordAssistPort) {
- this.recordAssistPort = recordAssistPort;
- }
-
- @Override
- public boolean isDocker() {
- return docker;
- }
-
- @Override
- public void setDocker(boolean docker) {
- this.docker = docker;
- }
-
public String getSdpIp() {
if (StringUtils.isEmpty(sdpIp)){
return ip;
@@ -295,13 +166,11 @@ public class MediaConfig implements IMediaServerItem {
}
}
-
-
public MediaServerItem getMediaSerItem(){
MediaServerItem mediaServerItem = new MediaServerItem();
mediaServerItem.setId(id);
mediaServerItem.setIp(ip);
- mediaServerItem.setDocker(true);
+ mediaServerItem.setDefaultServer(true);
mediaServerItem.setHookIp(hookIp);
mediaServerItem.setSdpIp(sdpIp);
mediaServerItem.setStreamIp(streamIp);
@@ -318,39 +187,12 @@ public class MediaConfig implements IMediaServerItem {
mediaServerItem.setRtpEnable(rtpEnable);
mediaServerItem.setRtpPortRange(rtpPortRange);
mediaServerItem.setRecordAssistPort(recordAssistPort);
- mediaServerItem.setCreateTime(createTime);
- mediaServerItem.setUpdateTime(updateTime);
- mediaServerItem.setCount(count);
- return mediaServerItem;
- }
-
- @Override
- public String getUpdateTime() {
- return updateTime;
- }
- @Override
- public void setUpdateTime(String updateTime) {
- this.updateTime = updateTime;
- }
+ SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+ mediaServerItem.setCreateTime(format.format(new Date(System.currentTimeMillis())));
+ mediaServerItem.setUpdateTime(format.format(new Date(System.currentTimeMillis())));
- @Override
- public String getCreateTime() {
- return createTime;
- }
-
- @Override
- public void setCreateTime(String createTime) {
- this.createTime = createTime;
- }
-
- @Override
- public int getCount() {
- return count;
+ return mediaServerItem;
}
- @Override
- public void setCount(int count) {
- this.count = count;
- }
}
diff --git a/src/main/java/com/genersoft/iot/vmp/conf/ProxyServletConfig.java b/src/main/java/com/genersoft/iot/vmp/conf/ProxyServletConfig.java
index c2fb3262..ab327b0e 100644
--- a/src/main/java/com/genersoft/iot/vmp/conf/ProxyServletConfig.java
+++ b/src/main/java/com/genersoft/iot/vmp/conf/ProxyServletConfig.java
@@ -1,6 +1,6 @@
package com.genersoft.iot.vmp.conf;
-import com.genersoft.iot.vmp.media.zlm.dto.IMediaServerItem;
+import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
import com.genersoft.iot.vmp.service.IMediaServerService;
import org.apache.catalina.connector.ClientAbortException;
import org.apache.http.HttpHost;
@@ -49,7 +49,7 @@ public class ProxyServletConfig {
@Override
protected String rewriteQueryStringFromRequest(HttpServletRequest servletRequest, String queryString) {
String queryStr = super.rewriteQueryStringFromRequest(servletRequest, queryString);
- IMediaServerItem mediaInfo = getMediaInfoByUri(servletRequest.getRequestURI());
+ MediaServerItem mediaInfo = getMediaInfoByUri(servletRequest.getRequestURI());
if (mediaInfo != null) {
if (!StringUtils.isEmpty(queryStr)) {
queryStr += "&secret=" + mediaInfo.getSecret();
@@ -88,7 +88,7 @@ public class ProxyServletConfig {
@Override
protected String getTargetUri(HttpServletRequest servletRequest) {
String requestURI = servletRequest.getRequestURI();
- IMediaServerItem mediaInfo = getMediaInfoByUri(requestURI);
+ MediaServerItem mediaInfo = getMediaInfoByUri(requestURI);
String uri = null;
if (mediaInfo != null) {
@@ -106,7 +106,7 @@ public class ProxyServletConfig {
@Override
protected HttpHost getTargetHost(HttpServletRequest servletRequest) {
String requestURI = servletRequest.getRequestURI();
- IMediaServerItem mediaInfo = getMediaInfoByUri(requestURI);
+ MediaServerItem mediaInfo = getMediaInfoByUri(requestURI);
HttpHost host;
if (mediaInfo != null) {
host = new HttpHost(mediaInfo.getIp(), mediaInfo.getHttpPort());
@@ -120,7 +120,7 @@ public class ProxyServletConfig {
/**
* 根据uri获取流媒体信息
*/
- IMediaServerItem getMediaInfoByUri(String uri){
+ MediaServerItem getMediaInfoByUri(String uri){
String[] split = uri.split("/");
String mediaServerId = split[2];
return mediaServerService.getOne(mediaServerId);
@@ -132,7 +132,7 @@ public class ProxyServletConfig {
@Override
protected String rewriteUrlFromRequest(HttpServletRequest servletRequest) {
String requestURI = servletRequest.getRequestURI();
- IMediaServerItem mediaInfo = getMediaInfoByUri(requestURI);
+ MediaServerItem mediaInfo = getMediaInfoByUri(requestURI);
String url = super.rewriteUrlFromRequest(servletRequest);
if (mediaInfo == null) {
return url;
@@ -186,7 +186,7 @@ public class ProxyServletConfig {
@Override
protected String getTargetUri(HttpServletRequest servletRequest) {
String requestURI = servletRequest.getRequestURI();
- IMediaServerItem mediaInfo = getMediaInfoByUri(requestURI);
+ MediaServerItem mediaInfo = getMediaInfoByUri(requestURI);
String uri = null;
if (mediaInfo != null) {
@@ -204,7 +204,7 @@ public class ProxyServletConfig {
@Override
protected HttpHost getTargetHost(HttpServletRequest servletRequest) {
String requestURI = servletRequest.getRequestURI();
- IMediaServerItem mediaInfo = getMediaInfoByUri(requestURI);
+ MediaServerItem mediaInfo = getMediaInfoByUri(requestURI);
HttpHost host;
if (mediaInfo != null) {
host = new HttpHost(mediaInfo.getIp(), mediaInfo.getRecordAssistPort());
@@ -218,7 +218,7 @@ public class ProxyServletConfig {
/**
* 根据uri获取流媒体信息
*/
- IMediaServerItem getMediaInfoByUri(String uri){
+ MediaServerItem getMediaInfoByUri(String uri){
String[] split = uri.split("/");
String mediaServerId = split[2];
return mediaServerService.getOne(mediaServerId);
@@ -230,7 +230,7 @@ public class ProxyServletConfig {
@Override
protected String rewriteUrlFromRequest(HttpServletRequest servletRequest) {
String requestURI = servletRequest.getRequestURI();
- IMediaServerItem mediaInfo = getMediaInfoByUri(requestURI);
+ MediaServerItem mediaInfo = getMediaInfoByUri(requestURI);
String url = super.rewriteUrlFromRequest(servletRequest);
if (mediaInfo == null) {
return url;
diff --git a/src/main/java/com/genersoft/iot/vmp/conf/RedisConfig.java b/src/main/java/com/genersoft/iot/vmp/conf/RedisConfig.java
index 0b3e23be..ee907882 100644
--- a/src/main/java/com/genersoft/iot/vmp/conf/RedisConfig.java
+++ b/src/main/java/com/genersoft/iot/vmp/conf/RedisConfig.java
@@ -1,5 +1,7 @@
package com.genersoft.iot.vmp.conf;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Value;
import org.springframework.cache.annotation.CachingConfigurerSupport;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@@ -10,6 +12,8 @@ import org.springframework.data.redis.serializer.StringRedisSerializer;
import com.alibaba.fastjson.parser.ParserConfig;
import com.genersoft.iot.vmp.utils.redis.FastJsonRedisSerializer;
+import redis.clients.jedis.JedisPool;
+import redis.clients.jedis.JedisPoolConfig;
/**
* @Description:Redis中间件配置类,使用spring-data-redis集成,自动从application.yml中加载redis配置
@@ -20,6 +24,37 @@ import com.genersoft.iot.vmp.utils.redis.FastJsonRedisSerializer;
@Configuration
public class RedisConfig extends CachingConfigurerSupport {
+ @Value("${spring.redis.host}")
+ private String host;
+ @Value("${spring.redis.port}")
+ private int port;
+ @Value("${spring.redis.database}")
+ private int database;
+ @Value("${spring.redis.password}")
+ private String password;
+ @Value("${spring.redis.timeout}")
+ private int timeout;
+ @Value("${spring.redis.poolMaxTotal:1000}")
+ private int poolMaxTotal;
+ @Value("${spring.redis.poolMaxIdle:500}")
+ private int poolMaxIdle;
+ @Value("${spring.redis.poolMaxWait:5}")
+ private int poolMaxWait;
+
+ @Bean
+ public JedisPool jedisPool() {
+ if (StringUtils.isBlank(password)) {
+ password = null;
+ }
+ JedisPoolConfig poolConfig = new JedisPoolConfig();
+ poolConfig.setMaxIdle(poolMaxIdle);
+ poolConfig.setMaxTotal(poolMaxTotal);
+ // 秒转毫秒
+ poolConfig.setMaxWaitMillis(poolMaxWait * 1000L);
+ JedisPool jp = new JedisPool(poolConfig, host, port, timeout * 1000, password, database);
+ return jp;
+ }
+
@Bean("redisTemplate")
public RedisTemplate