新增了放心签
This commit is contained in:
@@ -1,16 +1,24 @@
|
||||
package net.lab1024.sa.common.config;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonAutoDetect;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.PropertyAccessor;
|
||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.SerializationFeature;
|
||||
import com.fasterxml.jackson.databind.jsontype.impl.LaissezFaireSubTypeValidator;
|
||||
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Primary;
|
||||
import org.springframework.data.redis.connection.RedisConnectionFactory;
|
||||
import org.springframework.data.redis.core.*;
|
||||
import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
|
||||
import org.springframework.data.redis.serializer.StringRedisSerializer;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* redis配置
|
||||
*
|
||||
@@ -20,20 +28,29 @@ import org.springframework.data.redis.serializer.StringRedisSerializer;
|
||||
* @Email lab1024@163.com
|
||||
* @Copyright 1024创新实验室 ( https://1024lab.net )
|
||||
*/
|
||||
//@Configuration
|
||||
@Configuration
|
||||
public class RedisConfig {
|
||||
|
||||
@Autowired
|
||||
|
||||
@Resource
|
||||
private RedisConnectionFactory factory;
|
||||
|
||||
@Bean
|
||||
public RedisTemplate<String, Object> redisTemplate() {
|
||||
Jackson2JsonRedisSerializer<Object> jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer<Object>(Object.class);
|
||||
ObjectMapper om = new ObjectMapper();
|
||||
om.registerModule(new JavaTimeModule())
|
||||
.configure(SerializationFeature.WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS, false)
|
||||
.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false)
|
||||
.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
|
||||
.configure(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS, false)
|
||||
.setSerializationInclusion(JsonInclude.Include.NON_NULL);
|
||||
|
||||
om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
|
||||
om.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL);
|
||||
// enableDefaultTyping 官方已弃用 所以改为 activateDefaultTyping
|
||||
om.activateDefaultTyping(LaissezFaireSubTypeValidator.instance, ObjectMapper.DefaultTyping.NON_FINAL);
|
||||
jackson2JsonRedisSerializer.setObjectMapper(om);
|
||||
RedisTemplate<String, Object> template = new RedisTemplate<String, Object>();
|
||||
RedisTemplate<String, Object> template = new RedisTemplate<>();
|
||||
template.setConnectionFactory(factory);
|
||||
template.setKeySerializer(new StringRedisSerializer());
|
||||
template.setValueSerializer(jackson2JsonRedisSerializer);
|
||||
@@ -69,4 +86,5 @@ public class RedisConfig {
|
||||
return redisTemplate.opsForZSet();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -26,18 +26,18 @@ spring:
|
||||
matching-strategy: ant_path_matcher
|
||||
|
||||
# redis 连接池配置信息
|
||||
# redis:
|
||||
# database: 1
|
||||
# host: 127.0.0.1
|
||||
# lettuce:
|
||||
# pool:
|
||||
# max-active: 5
|
||||
# min-idle: 1
|
||||
# max-idle: 3
|
||||
# max-wait: 30000ms
|
||||
# port: 6379
|
||||
# timeout: 10000ms
|
||||
# password:
|
||||
redis:
|
||||
database: 11
|
||||
host: '139.155.127.177'
|
||||
lettuce:
|
||||
pool:
|
||||
max-active: 5
|
||||
min-idle: 1
|
||||
max-idle: 3
|
||||
max-wait: 30000ms
|
||||
port: 30002
|
||||
timeout: 3000
|
||||
password: gdxz2022&dj.
|
||||
|
||||
# 上传文件大小配置
|
||||
servlet:
|
||||
|
||||
Reference in New Issue
Block a user