设置redis的连接工厂对象
This commit is contained in:
parent
a3218d4b3a
commit
cf32a6bd8f
|
@ -0,0 +1,25 @@
|
||||||
|
package com.sky.config;
|
||||||
|
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Configurable;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.data.redis.connection.RedisConnectionFactory;
|
||||||
|
import org.springframework.data.redis.core.RedisTemplate;
|
||||||
|
import org.springframework.data.redis.serializer.StringRedisSerializer;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
|
@Configurable
|
||||||
|
@Slf4j
|
||||||
|
public class RedisConfiguration {
|
||||||
|
@Resource
|
||||||
|
RedisTemplate<String, String> redisTemplate;
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public RedisTemplate<String, String> redisTemplate(RedisConnectionFactory redisConnectionFactory) {
|
||||||
|
// 设置redis的连接工厂对象
|
||||||
|
redisTemplate.setConnectionFactory(redisConnectionFactory);
|
||||||
|
redisTemplate.setKeySerializer(new StringRedisSerializer());
|
||||||
|
return redisTemplate;
|
||||||
|
}
|
||||||
|
}
|
|
@ -11,4 +11,8 @@ sky:
|
||||||
bucket-name: sky
|
bucket-name: sky
|
||||||
accessKey: "bunny"
|
accessKey: "bunny"
|
||||||
secretKey: "02120212"
|
secretKey: "02120212"
|
||||||
|
redis:
|
||||||
|
host: 106.15.251.123
|
||||||
|
port: 6378
|
||||||
|
password: "02120212"
|
||||||
|
database: 1
|
||||||
|
|
|
@ -16,6 +16,13 @@ spring:
|
||||||
multipart:
|
multipart:
|
||||||
max-file-size: 10MB
|
max-file-size: 10MB
|
||||||
max-request-size: 10MB
|
max-request-size: 10MB
|
||||||
|
redis:
|
||||||
|
host: ${sky.redis.host}
|
||||||
|
port: ${sky.redis.port}
|
||||||
|
password: ${sky.redis.password}
|
||||||
|
database: ${sky.redis.database}
|
||||||
|
timeout: 5000
|
||||||
|
|
||||||
|
|
||||||
mybatis:
|
mybatis:
|
||||||
#mapper配置文件
|
#mapper配置文件
|
||||||
|
|
Loading…
Reference in New Issue