When I was learning redisson distributed lock, I reported such a mistake. After searching the information, I found out that there is no redis permission.
Solution:
Add a password to the configuration file:
import org.redisson.Redisson;
import org.redisson.config.Config;
import org.redisson.api.RedissonClient;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import java.io.IOException;
/**
* @author 86150
*/
@Configuration
public class MyRedissonConfig {
@Bean(destroyMethod = "shutdown")
RedissonClient redisson() throws IOException {
Config config = new Config();
//集群模式
//config.useClusterServers().addNodeAddress("127.0.0.1:7004","127.0.0.1:7001");
//单节点模式
config.useSingleServer().setAddress("redis://x.xx.155.4:6379").setPassword("2323");
return Redisson.create(config);
}
}
If it is a specified database, you can add it: