增加redisson配置
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
package com.volvo.ai.analytic.center.config;
|
||||
|
||||
import org.redisson.Redisson;
|
||||
import org.redisson.api.RedissonClient;
|
||||
import org.redisson.config.Config;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.cloud.context.config.annotation.RefreshScope;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration
|
||||
@RefreshScope
|
||||
public class RedissonConfig {
|
||||
|
||||
@Value("${spring.redis.host}")
|
||||
private String host;
|
||||
|
||||
@Value("${spring.redis.port}")
|
||||
private String port;
|
||||
|
||||
@Value("${spring.redis.password}")
|
||||
private String password;
|
||||
|
||||
@Value("${spring.redis.username}")
|
||||
private String userName;
|
||||
|
||||
@Bean(destroyMethod = "shutdown")
|
||||
public RedissonClient redissonClient() {
|
||||
Config config = new Config();
|
||||
config.useSingleServer()
|
||||
.setAddress("redis://" + host + ":" + port)
|
||||
.setPassword(password).setUsername(userName)
|
||||
.setDatabase(0)
|
||||
.setConnectionMinimumIdleSize(5)
|
||||
.setIdleConnectionTimeout(10000)
|
||||
.setConnectTimeout(10000)
|
||||
.setTimeout(3000);
|
||||
return Redisson.create(config);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user