Commit 9af9691f authored by zhangyong's avatar zhangyong
parents 51f47e37 5b09e1ee
package com.egolm.shop.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
import org.springframework.data.redis.serializer.StringRedisSerializer;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.PropertyAccessor;
import com.fasterxml.jackson.databind.ObjectMapper;
@Configuration
public class RedisConfig {
@Bean
public RedisTemplate<String, ?> getRedisTemplate(RedisConnectionFactory connectionFactory) {
RedisTemplate<String, ?> template = new RedisTemplate<>();
template.setConnectionFactory(connectionFactory);
Jackson2JsonRedisSerializer<?> valueSerializer = new Jackson2JsonRedisSerializer<Object>(Object.class);
ObjectMapper mapper = new ObjectMapper();
mapper.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
mapper.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL);
valueSerializer.setObjectMapper(mapper);
template.setValueSerializer(valueSerializer);
template.setKeySerializer(new StringRedisSerializer());
template.afterPropertiesSet();
return template;
}
}
......@@ -17,5 +17,17 @@ spring.datasource.password=qiyang@2013
spring.datasource.url=jdbc:sqlserver://10.10.0.22:1433;instanceName=SQLSERVER;DatabaseName=EGOLMDEV
spring.datasource.driver-class-name=com.microsoft.sqlserver.jdbc.SQLServerDriver
spring.datasource.testWhileIdle=true
spring.datasource.validationQueryTimeout=5
spring.datasource.validationQuery=SELECT 1
spring.datasource.timeBetweenEvictionRunsMillis=3600000
spring.redis.database=0
spring.redis.host=ossip.cn
spring.redis.port=6379
spring.redis.password=@8UiMqvDtNgv
spring.redis.timeout=2000
spring.redis.pool.max-active=20
spring.redis.pool.max-wait=2000
spring.redis.pool.max-idle=5
spring.redis.pool.min-idle=0
\ No newline at end of file
......@@ -17,5 +17,17 @@ spring.datasource.password=qiyang
spring.datasource.url=jdbc:sqlserver://10.10.0.51:56443;instanceName=SQLSERVER;DatabaseName=EGOLMSAAS
spring.datasource.driver-class-name=com.microsoft.sqlserver.jdbc.SQLServerDriver
spring.datasource.testWhileIdle=true
spring.datasource.validationQueryTimeout=5
spring.datasource.validationQuery=SELECT 1
spring.datasource.timeBetweenEvictionRunsMillis=3600000
spring.redis.database=0
spring.redis.host=ossip.cn
spring.redis.port=6379
spring.redis.password=@8UiMqvDtNgv
spring.redis.timeout=2000
spring.redis.pool.max-active=20
spring.redis.pool.max-wait=2000
spring.redis.pool.max-idle=5
spring.redis.pool.min-idle=0
\ No newline at end of file
......@@ -17,5 +17,17 @@ spring.datasource.password=qiyang
spring.datasource.url=jdbc:sqlserver://10.10.0.51:56443;instanceName=SQLSERVER;DatabaseName=EGOLMSAAS
spring.datasource.driver-class-name=com.microsoft.sqlserver.jdbc.SQLServerDriver
spring.datasource.testWhileIdle=true
spring.datasource.validationQueryTimeout=5
spring.datasource.validationQuery=SELECT 1
spring.datasource.timeBetweenEvictionRunsMillis=3600000
spring.redis.database=0
spring.redis.host=ossip.cn
spring.redis.port=6379
spring.redis.password=@8UiMqvDtNgv
spring.redis.timeout=2000
spring.redis.pool.max-active=20
spring.redis.pool.max-wait=2000
spring.redis.pool.max-idle=5
spring.redis.pool.min-idle=0
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment