Commit 2dfe1d79 authored by 张永's avatar 张永

加redis

parent b31f10b6
Pipeline #168 failed with stages
......@@ -25,6 +25,10 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
......
package com.egolm.admin.config;
import org.springframework.beans.factory.annotation.Qualifier;
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
@Qualifier("redisTemplate")
public RedisTemplate<String, ?> redisTemplate(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;
}
}
......@@ -10,7 +10,7 @@ spring.http.multipart.maxRequestSize=5MB
spring.http.encoding.force=true
spring.http.encoding.enabled=true
spring.http.encoding.charset=utf-8
spring.main.allow-bean-definition-overriding=true
spring.datasource.config.url=jdbc:mysql://10.10.0.20:3306/msgcenter?useSSL=false
spring.datasource.config.username=root
......@@ -29,3 +29,14 @@ spring.datasource.shop.testWhileIdle=true
spring.datasource.shop.validationQueryTimeout=5
spring.datasource.shop.validationQuery=SELECT 1
spring.datasource.shop.timeBetweenEvictionRunsMillis=3600000
######redis
spring.redis.host=10.10.0.15
spring.redis.port=16379
spring.redis.database=10
spring.redis.password=
spring.redis.timeout=3000
spring.redis.jedis.max-active=5
spring.redis.jedis.max-idle=5
spring.redis.jedis.max-wait=5
\ No newline at end of file
......@@ -11,6 +11,8 @@ spring.http.encoding.force=true
spring.http.encoding.enabled=true
spring.http.encoding.charset=utf-8
spring.main.allow-bean-definition-overriding=true
spring.datasource.config.url=jdbc:mysql://10.10.0.20:3306/msgcenter?useSSL=false
spring.datasource.config.username=root
......@@ -29,3 +31,14 @@ spring.datasource.shop.testWhileIdle=true
spring.datasource.shop.validationQueryTimeout=5
spring.datasource.shop.validationQuery=SELECT 1
spring.datasource.shop.timeBetweenEvictionRunsMillis=3600000
######redis
spring.redis.host=10.10.0.15
spring.redis.port=16379
spring.redis.database=10
spring.redis.password=
spring.redis.timeout=3000
spring.redis.jedis.max-active=5
spring.redis.jedis.max-idle=5
spring.redis.jedis.max-wait=5
\ No newline at end of file
......@@ -11,6 +11,7 @@ spring.http.encoding.force=true
spring.http.encoding.enabled=true
spring.http.encoding.charset=utf-8
spring.main.allow-bean-definition-overriding=true
spring.datasource.config.url=jdbc:mysql://10.10.0.20:3306/msgcenter?useSSL=false
spring.datasource.config.username=root
......@@ -29,3 +30,13 @@ spring.datasource.shop.testWhileIdle=true
spring.datasource.shop.validationQueryTimeout=5
spring.datasource.shop.validationQuery=SELECT 1
spring.datasource.shop.timeBetweenEvictionRunsMillis=3600000
######redis
spring.redis.host=10.10.0.15
spring.redis.port=16379
spring.redis.database=10
spring.redis.password=
spring.redis.timeout=3000
spring.redis.jedis.max-active=5
spring.redis.jedis.max-idle=5
spring.redis.jedis.max-wait=5
\ 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