为什么在application.properties文件中配置一下信息,就能够自动使用redis集群?
spring-boot-autoconfigure包中
org.springframework.boot.autoconfigure.data.redis.RedisProperties 这个配置类设置了redis的配置属性
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//
package org.springframework.boot.autoconfigure.data.redis;
import java.time.Duration;
import java.util.List;
import org.springframework.boot.context.properties.ConfigurationProperties;
@ConfigurationProperties(
prefix = "spring.redis"
)
public class RedisProperties {
private int database = 0;
private String url;
private String host = "localhost";
private String password;
private int port = 6379;
private boolean ssl;
private Duration timeout;
private RedisProperties.Sentinel sentinel;
private RedisProperties.Cluster cluster;
private final RedisProperties.Jedis jedis = new RedisProperties.Jedis();
private final RedisProperties.Lettuce lettuce = new RedisProperties.Lettuce();
public RedisProperties() {
}
public int getDatabase() {
return this.database;
}
public void setDatabase(int database) {
this.database = database;
}
public String getUrl() {
return this.url;
}
public void setUrl(String url) {
this.url = url;
}
public String getHost() {
return this.host;
}
public void setHost(String host) {
this.host = host;
}
public String getPassword() {
return this.password;
}
public void setPassword(String password) {
this.password = password;
}
public int getPort() {
return this.port;
}
public void setPort(int port) {
this.port = port;
}
public boolean isSsl() {
return this.ssl;
}
public void setSsl(boolean ssl) {
this.ssl = ssl;
}
public void setTimeout(Duration timeout) {
this.timeout = timeout;
}
public Duration getTimeout() {
return this.timeout;
}
public RedisProperties.Sentinel getSentinel() {
return this.sentinel;
}
public void setSentinel(RedisProperties.Sentinel sentinel) {
this.sentinel = sentinel;
}
public RedisProperties.Cluster getCluster() {
return this.cluster;
}
public void setCluster(RedisProperties.Cluster cluster) {
this.cluster = cluster;
}
public RedisProperties.Jedis getJedis() {
return this.jedis;
}
public RedisProperties.Lettuce getLettuce() {
return this.lettuce;
}
public