SpringBoot 整合 Redis 报错 The URL is not valid for configuring Spring Data Redis.

557 阅读1分钟

整合 Redis 时 url 配置报错: SpringBoot 整合 Redis 报错 The URL is not valid for configuring Spring Data Redis. The scheme 'null' is not supported

项目环境:

  • SpringBoot 2.3.7.RELEASE

pom.xml 文件引入的依赖:

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>

application.yml 文件配置

spring:
  redis:
    url: 127.0.0.1
    port: 6379
    password: iampw

启动项目报错信息:

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2022-08-19 21:37:45.758 ERROR 9140 --- [           main] o.s.b.d.LoggingFailureAnalysisReporter   : 

***************************
APPLICATION FAILED TO START
***************************

Description:
# url 对于 Spring Data Redis 无效,不支持 协议 为 null
The URL '127.0.0.1' is not valid for configuring Spring Data Redis. The scheme 'null' is not supported.

Action:
# 使用不安全的协议 redis:// 或者使用安全的协议 rediss://
Use the scheme 'redis://` for insecure or `rediss://` for secure Redis standalone configuration.

解决

修改 yml 文件,使用redis 的 url 协议

spring:
  redis:
    url: redis://iampw@127.0.0.1:6379