配置两个bean:
JedisConnectionFactory 和 RedisTemplate JedisConnectionFactory factory = new JedisConnectionFactory();//redisSentinelConfiguration()
try {Yaml yaml = new Yaml();InputStream resourceAsStream = SMSUtil.class.getClassLoader().getResourceAsStream("application.yml");JSONObject redisObj = JSONObject.parseObject(JSONObject.toJSONString( yaml.load(resourceAsStream))).getJSONObject("spring")...
在后面加上ms即可,但是早期版本的IDEA可以不加ms
# REDIS (RedisProperties)
# Redis数据库索引(默认为0)
spring.redis.database=0
# Redis服务器地址
spring.redis.host=localhost
# Redis服务器连接端口
spring.redis.port=6379
# Redis服务器连接密码(默认为空)
spring.redis.password=
# 连接池最大连接数(使用负值表示没有限制)
spring.redis.jedis.pool.max-active=8
# 连接池最大阻塞等待时间(使用负值表示没有限制)
spring.redis.jedis.pool.max-wait=-1
# 连接池...
我有Spring Redis使用spring-data-redis工作,所有默认配置都喜欢localhost默认端口,依此类推.
现在我尝试通过在application.properties文件中配置它来进行相同的配置.但我无法弄清楚我应该如何创建完全符合我的属性值的bean.
Redis配置文件@EnableRedisHttpSession
@Configuration
public class SpringSessionRedisConfiguration {@Bean
JedisConnectionFactory connectionFactory() {return new JedisConnectionFactory();
}@Auto...
#### env:${env}redis.maxIdle=80
##最小空闲数redis.minIdle=10
##最大连接数:能够同时建立的“最大链接个数”redis.maxTotal=500
#每次最大连接数redis.numTestsPerEvictionRun=1024
##最大建立连接等待时间:单位ms##当borrow一个jedis实例时,最大的等待时间,如果超过等待时间,则直接抛出JedisConnectionException;redis.maxWait=5000
##使用连接时,检测连接是否成功 redis.testOnBorrow=true
#连接耗尽时是否阻塞,false...