
springboot 配置 redis 报 connection reset 错误
在 springboot 3.x 版本中配置 redis 客户端时,部分用户遇到了终端提示 "connection reset" 的错误。虽然数据看似可以写入 redis(出现乱码),但读出后为空。
出现此问题的原因是:
解决方法:
配置范例:
// pom.xml
<!-- https://mvnrepository.com/artifact/org.springframework.data/spring-data-redis -->
<dependency>
<groupid>org.springframework.data</groupid>
<artifactid>spring-data-redis</artifactid>
<version>3.4.3</version>
</dependency>
// application.properties
spring.redis.host=localhost
spring.redis.port=6379示例代码:
@SpringBootApplication
public class Application { public static void main(String[] args) { SpringApplication.run(Application.class, args); } }
@RestController
public class Controller { @Autowired private RedisTemplate<String, String> redisTemplate;
@GetMapping("/") public String index() { redisTemplate.opsForValue().set("key", "value"); return "Hello, World!"; } }以上就是SpringBoot 3.x 配置Redis连接重置错误:如何解决Redis版本不兼容问题?的详细内容,更多请关注php中文网其它相关文章!
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号