配置文件
yaml文件
spring:
redis: #默认数据源
expireSeconds: 120
commandTimeout: 10000 #redis操作的超时时间
pool:
maxActive: 5000 #最大连接数
maxIdle: 30 #最大空闲连接数
minIdle: 5 #最小空闲连接数
maxWait: 3000
password: 123456
host: 127.0.0.1
port: 6379
secondary-redis: #第二个数据源
expireSeconds: 120
commandTimeout: 10000 #redis操作的超时时间
pool:
maxActive: 5000 #最大连接数
maxIdle: 30 #最大空闲连接数
minIdle: 5 #最小空闲连接数
maxWait: 3000
password: 123456
host: 127.0.0.1
port: 6379
配置类
redis配置类
@Configuration
public class RedisConfig {
@Value("${spring.redis.host}")
private String firstRedisHost;
@Value("${spring.redis.port}")
private Integer firstRedisPort;
@Value("${spring.redis.password:}")
private String firstRedisPassword;
@Value("${spring.redis.pool.maxIdle}&
最低0.47元/天 解锁文章
1739

被折叠的 条评论
为什么被折叠?



