Support spring session #48
This commit is contained in:
19
pom.xml
19
pom.xml
@@ -38,10 +38,22 @@
|
||||
<reactor-bom.version>Dysprosium-SR16</reactor-bom.version>
|
||||
<lettuce.version>5.3.6.RELEASE</lettuce.version>
|
||||
<nacos.version>0.2.7</nacos.version>
|
||||
<netty.version>4.1.58.Final</netty.version>
|
||||
<netty.version>4.1.58.Final</netty.version>
|
||||
<httpcore.version>4.4.14</httpcore.version>
|
||||
<log4j2.version>2.13.3</log4j2.version>
|
||||
</properties>
|
||||
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.session</groupId>
|
||||
<artifactId>spring-session-bom</artifactId>
|
||||
<version>Dragonfruit-RELEASE</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
@@ -196,6 +208,11 @@
|
||||
<version>3.1.6.4</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.session</groupId>
|
||||
<artifactId>spring-session-data-redis</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!--<dependency>
|
||||
<groupId>io.netty</groupId>
|
||||
<artifactId>netty-transport-native-epoll</artifactId>
|
||||
|
||||
@@ -23,6 +23,7 @@ import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Primary;
|
||||
import org.springframework.dao.DataAccessException;
|
||||
import org.springframework.data.redis.connection.ReactiveRedisClusterConnection;
|
||||
import org.springframework.data.redis.connection.ReactiveRedisConnection;
|
||||
@@ -33,7 +34,13 @@ import org.springframework.data.redis.connection.RedisConnectionFactory;
|
||||
import org.springframework.data.redis.connection.RedisSentinelConnection;
|
||||
import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory;
|
||||
import org.springframework.data.redis.core.ReactiveStringRedisTemplate;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.data.redis.listener.ReactiveRedisMessageListenerContainer;
|
||||
import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer;
|
||||
import org.springframework.data.redis.serializer.RedisSerializer;
|
||||
import org.springframework.data.redis.serializer.StringRedisSerializer;
|
||||
import org.springframework.session.data.redis.config.annotation.SpringSessionRedisConnectionFactory;
|
||||
|
||||
import we.log.LogSendAppender;
|
||||
import we.log.RedisLogSendServiceImpl;
|
||||
|
||||
@@ -108,7 +115,41 @@ public class AggregateRedisConfig extends RedisReactiveConfig {
|
||||
@Qualifier(AGGREGATE_REACTIVE_REDIS_CONNECTION_FACTORY) ReactiveRedisConnectionFactory factory) {
|
||||
return new ReactiveRedisMessageListenerContainer(factory);
|
||||
}
|
||||
|
||||
/**
|
||||
* Spring Session Redis
|
||||
*/
|
||||
@Bean
|
||||
@SpringSessionRedisConnectionFactory
|
||||
public LettuceConnectionFactory springSessionRedisConnectionFactory(){
|
||||
return (LettuceConnectionFactory) super.lettuceConnectionFactory();
|
||||
}
|
||||
|
||||
/**
|
||||
* Spring session redis serializer
|
||||
* @return
|
||||
*/
|
||||
@Bean("springSessionDefaultRedisSerializer")
|
||||
public RedisSerializer<Object> defaultRedisSerializer() {
|
||||
return new GenericJackson2JsonRedisSerializer();
|
||||
}
|
||||
|
||||
/**
|
||||
* Default RedisTemplate
|
||||
* @return
|
||||
*/
|
||||
@Bean
|
||||
@Primary
|
||||
public RedisTemplate<Object, Object> redisTemplate() {
|
||||
RedisTemplate<Object, Object> template = new RedisTemplate<>();
|
||||
template.setConnectionFactory((RedisConnectionFactory) lettuceConnectionFactory());
|
||||
template.setKeySerializer(new StringRedisSerializer());
|
||||
template.setHashKeySerializer(new StringRedisSerializer());
|
||||
template.setValueSerializer(new GenericJackson2JsonRedisSerializer());
|
||||
template.setHashValueSerializer(new GenericJackson2JsonRedisSerializer());
|
||||
return template;
|
||||
}
|
||||
|
||||
public boolean getSendLogOpen() {
|
||||
return sendLogOpen;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user