admin管理员组文章数量:1608599
报错信息
SpringBoot集成Redis报错原因:
需要注释redis.conf配置文件下的 bind 127.0.0.1
查看linux下的ip
ifconfig
关闭防火墙
查看指令:systemctl status firewalld
关闭指令:systemctl stop firewalld
启动服务 (123 是我自己设置的密码,可在redis.conf设置)
最后,别忘了修改redis配置文件ip
# Redis数据库索引(默认为0)
spring.redis.database=0
# Redis服务器地址
spring.redis.host=192.168.20.128
# Redis服务器连接端口
spring.redis.port=6379
# Redis服务器连接密码(默认为空)
spring.redis.password=123
# 连接池最大连接数(使用负值表示没有限制)
spring.redis.pool.max-active=8
# 连接池最大阻塞等待时间(使用负值表示没有限制)
spring.redis.pool.max-wait=-1
# 连接池中的最大空闲连接
spring.redis.pool.max-idle=8
# 连接池中的最小空闲连接
spring.redis.pool.min-idle=0
# 连接超时时间(毫秒)
spring.redis.timeout=5000
测试
导入依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
测试
@Autowired
private RedisTemplate redisTemplate;
@Test
void contextLoads() {
redisTemplate.opsForValue().set("wwz","wangwenzhuo");
System.out.println(redisTemplate.opsForValue().get("wwz"));
}
成功
本文标签: 报错JavaSpringBootRedisNET
版权声明:本文标题:SpringBoot集成Redis报错(java.net.ConnectException: Connection refused: no further information) 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://www.elefans.com/xitong/1728548080a1163102.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论