使用JDK21 SpringBoot3.4.3

yaml配置

spring:
  data:
    redis:
      host: 127.0.0.1
      port: 6379
      database: 0
      # 读超时
      timeout: 3000
      # 连接超时
      connectTimeout: 5000
      # Lettuce连接池
      lettuce:
        pool:
          # 最小空闲连接
          min-idle: 5
          # 最大空闲连接
          max-idle: 10
          # 最大连接数
          max-active: 100
          # 连接分配应该阻塞的最大时间
          max-wait: 2000

Pom


            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-data-redis</artifactId>
                <version>${spring-boot.version}</version>
            </dependency>

问题原因

我是使用阿里云镜像,不保熟

项目运行报错:Caused by: java.lang.NoClassDefFoundError: org/springframework/data/redis/serializer/RedisSerializer

r :java.lang.NoClassDefFoundError: org/springframework/data/redis/serializer/RedisSerializer · Issue #8652 · spring-projects/spring-boot

Sounds like you have a corrupted download of the spring-data-redis jar. Try clearing out your Maven cache and building again.

听起来你有一个损坏的下载的spring-data-redis罐。尝试清除您的Maven缓存并重新构建。

解决方法

  1. 查看External Libraries是否有类文件(有这个依赖,类是空的)
  2. 在maven中找到该文件夹,删除重新瞎下载,查看是否有类文件(删除,重新clean install测试,查看是否有类文件)
  3. 确定阿里云缓存问题
  4. 删除项目阿里云镜像地址
  5. 删除maven setting 镜像地址
  6. 用原始仓库下载,没有科学代理洗洗下班睡觉