<dependency>
<groupId>com.itopener</groupId>
<artifactId>redisson-spring-boot-starter</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>
spring.redisson.config-file.json=classpath:redisson.json
{
"singleServerConfig":{
"idleConnectionTimeout":10000,
"pingTimeout":1000,
"connectTimeout":10000,
"timeout":3000,
"retryAttempts":3,
"retryInterval":1500,
"password":"123456",
"subscriptionsPerConnection":5,
"clientName":null,
"address": "redis://127.0.0.1:6379",
"subscriptionConnectionMinimumIdleSize":1,
"subscriptionConnectionPoolSize":50,
"connectionMinimumIdleSize":32,
"connectionPoolSize":64,
"database":14
},
"threads":0,
"nettyThreads":0,
"codec":{
"class":"org.redisson.codec.JsonJacksonCodec"
},
"transportMode":"NIO"
}
首先请确保Spring Session library的依赖已经添加到了您的项目中:
Maven
<dependency>
<groupId>org.springframework.session</groupId>
<artifactId>spring-session-core</artifactId>
<version>2.0.5.RELEASE</version>
</dependency>
然后将@EnableRedissonHttpSession注释和Redisson实例添加到Spring的配置里:
@EnableRedissonHttpSession
public class Config {
//创建实例已经在整合redisson时启动了,所以这里不需要再启动
//@Bean
//public RedissonClient redisson() {
// return Redisson.create();
//}
}
然后提供一个启动器AbstractHttpSessionApplicationInitializer的扩展就行了:
public class Initializer extends AbstractHttpSessionApplicationInitializer {
public Initializer() {
super(Config.class);
}
}
到这里就大功告成,下续有需要再补充。。。。
https://github.com/redisson/redisson/wiki/14.-第三方框架整合
https://my.oschina.net/dengfuwei/blog/1603130