SpringBoot Redis 启动失败深度剖析与标准化解决方案(快速定位问题)

 更新时间:2025年11月18日 09:51:07   作者:独角鲸网络安全实验室  
本文基于SpringBoot 2.x/3.x(含Jakarta EE适配)与Redis 6.x/7.x生态,系统梳理12类常见错误,涵盖错误现象、深层原因、解决方案及最佳实践,助力开发者快速定位问题,感兴趣的朋友跟随小编一起看看吧

SpringBoot作为主流开发框架,其与Redis的整合因缓存、会话共享等场景被广泛应用,但启动阶段常因依赖配置、服务状态、版本兼容、网络环境等问题导致失败。本文基于SpringBoot 2.x/3.x(含Jakarta EE适配)与Redis 6.x/7.x生态,系统梳理12类常见错误,涵盖错误现象、深层原因、解决方案及最佳实践,助力开发者快速定位问题。

一、依赖配置类错误(基础高频)

1. 核心依赖缺失或版本冲突

错误现象

Caused by: java.lang.ClassNotFoundException: org.springframework.data.redis.core.RedisTemplate
# 或
Caused by: NoSuchMethodError: org.springframework.data.redis.connection.RedisConnectionFactory.getConnection()Lorg/springframework/data/redis/connection/RedisConnection;

错误原因

  • 未引入spring-boot-starter-data-redis核心依赖,导致Redis相关Bean无法加载;
  • SpringBoot版本与spring-data-redis/Redis客户端(Jedis/Lettuce)版本不兼容(如SpringBoot 3.x需搭配spring-data-redis 3.x,否则出现类方法缺失);
  • 手动指定了Redis客户端版本,与SpringBoot自动管理的版本冲突。

解决方案

  • 规范依赖配置(SpringBoot 2.x/3.x通用,推荐 Lettuce 客户端,默认集成):
    <!-- SpringBoot 2.x (Java EE) -->
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-redis</artifactId>
    </dependency>
    <!-- SpringBoot 3.x (Jakarta EE),依赖兼容无差异,核心组件版本自动升级 -->
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-redis</artifactId>
    </dependency>
  • 避免手动指定spring-data-redislettuce-corejedis版本,依赖SpringBoot的parentdependency-management自动管理;
  • 若需切换为Jedis客户端,需排除Lettuce并引入Jedis依赖:
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-redis</artifactId>
        <exclusions>
            <exclusion>
                <groupId>io.lettuce</groupId>
                <artifactId>lettuce-core</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>redis.clients</groupId>
        <artifactId>jedis</artifactId>
    </dependency>

2. 配置文件语法错误或关键项缺失

错误现象

Caused by: org.springframework.boot.context.properties.bind.BindException: Failed to bind properties under 'spring.redis' to org.springframework.boot.autoconfigure.data.redis.RedisProperties
# 或
IllegalArgumentException: Host name must not be null

错误原因

  • 配置项拼写错误(如spring.redis.host误写为spring.redis.hostnamespring.redis.port误写为spring.redis.portnum);
  • 关键配置项缺失(如未指定spring.redis.host,默认值localhost但本地无Redis服务);
  • YAML配置缩进错误(如层级错乱导致属性无法绑定);
  • 密码含特殊字符(如@#&)未转义,导致配置解析失败。

解决方案

  • 标准配置模板(YAML格式,覆盖核心场景):
    spring:
      redis:
        host: 127.0.0.1  # 必配,Redis服务IP(Docker部署需用容器IP或端口映射后的宿主机IP)
        port: 6379       # 必配,默认6379,若修改需同步Redis配置
        password: 123456 # 可选,Redis未设密码则省略(注意:若Redis设密码但此处未配,启动会报AUTH失败)
        database: 0      # 可选,默认0号库,需确保Redis已启用该库
        timeout: 3000    # 可选,连接超时时间(毫秒),建议设置避免无限等待
        # Lettuce客户端配置(默认使用)
        lettuce:
          pool:
            max-active: 8    # 最大连接数,默认8
            max-idle: 8      # 最大空闲连接数,默认8
            min-idle: 2      # 最小空闲连接数,默认2
            max-wait: -1     # 最大等待时间(毫秒),-1表示无限制
        # 若使用Jedis,替换为jedis节点(配置项与lettuce一致)
        # jedis:
        #   pool:
        #     max-active: 8
  • 密码含特殊字符时,用单引号包裹或URL编码(如密码a@b#123需写为'a@b#123'a%40b%23123);
  • 验证配置绑定:通过@ConfigurationProperties(prefix = "spring.redis")自定义配置类,打印属性值确认是否绑定成功。

二、Redis服务端相关错误(连接层核心)

1. Redis服务未启动或端口占用

错误现象

Caused by: io.lettuce.core.RedisConnectionException: Unable to connect to 127.0.0.1:6379
# 或
java.net.ConnectException: Connection refused: connect

错误原因

  • Redis服务未启动(Windows需手动启动redis-server.exe,Linux需执行systemctl start redis);
  • 目标端口被其他进程占用(如6379被其他应用占用,Redis启动失败导致无法连接);
  • Docker部署Redis时,未启动容器或容器未正常运行(docker ps查看容器状态)。

解决方案

  • 验证Redis服务状态
    • 本地部署:执行redis-cli ping,返回PONG说明服务正常;若提示“could not connect”,执行redis-server /etc/redis/redis.conf(Linux)或双击redis-server.exe(Windows)启动;
    • Docker部署:执行docker start [容器ID/名称]启动容器,若启动失败,通过docker logs [容器ID]查看日志(如端口冲突、配置文件挂载错误);
  • 排查端口占用
    • Windows:netstat -ano | findstr "6379",找到占用进程并结束(任务管理器->详细信息);
    • Linux:netstat -tulpn | grep 6379,通过kill -9 [PID]终止占用进程;
  • 若需修改Redis端口,需同步修改redis.conf中的port项与SpringBoot配置文件的spring.redis.port

2. 密码错误或未开启认证

错误现象

Caused by: io.lettuce.core.RedisCommandExecutionException: NOAUTH Authentication required.
# 或
WRONGPASS invalid username-password pair

错误原因

  • Redis已通过requirepass配置密码,但SpringBoot配置文件未指定spring.redis.password
  • spring.redis.password配置值与Redis实际密码不一致(含大小写、空格差异);
  • Redis启用了ACL用户认证(Redis 6.0+新特性),未配置用户名或用户名/密码不匹配。

解决方案

  • 验证Redis密码:执行redis-cli -h [IP] -p [端口] auth [密码],返回OK说明密码正确;
  • 若Redis未设密码:删除spring.redis.password配置,或在Redis中执行config set requirepass ""清空密码;
  • 若启用Redis ACL:需额外配置用户名(SpringBoot 2.7+支持):
    spring:
      redis:
        username: default  # 默认用户名,若自定义需修改
        password: 123456
  • 避免密码明文配置:生产环境通过配置中心(Nacos/Apollo)或环境变量注入,如spring.redis.password=${REDIS_PASSWORD}

3. 保护模式拦截(Redis默认开启)

错误现象

Caused by: io.lettuce.core.RedisCommandExecutionException: DENIED Redis is running in protected mode because protected mode is enabled, no bind address was specified, no authentication password is requested to clients.

错误原因

Redis默认启用保护模式(protected-mode yes),当满足以下条件时拒绝外部连接:

  • 未通过bind配置绑定IP;
  • 未设置密码;
  • 外部IP(非127.0.0.1)访问。

解决方案

  • 开发/测试环境:临时关闭保护模式(不推荐生产环境):
    1. 执行redis-cli config set protected-mode no(临时生效,重启失效);
    2. 永久生效:修改redis.conf,设置protected-mode no,重启Redis;
  • 生产环境(推荐):
    1. 绑定允许访问的IP:bind 127.0.0.1 192.168.1.100(多个IP用空格分隔);
    2. 设置Redis密码:requirepass 123456
    3. 重启Redis使配置生效。

4. 防火墙/安全组拦截

错误现象

java.net.SocketTimeoutException: Connect timed out
# 或
io.lettuce.core.RedisConnectionException: Connection timed out: /192.168.1.200:6379

错误原因

  • Redis服务器所在主机的防火墙(Linux iptables/Windows防火墙)未开放6379端口;
  • 云服务器(阿里云/腾讯云/华为云)未在安全组中放行6379端口(入方向);
  • 跨网段访问时,路由策略限制导致网络不通。

解决方案

  • Linux防火墙配置(以CentOS为例):
    # 开放6379端口(永久生效)
    firewall-cmd --permanent --add-port=6379/tcp
    # 重新加载防火墙规则
    firewall-cmd --reload
    # 验证端口是否开放
    firewall-cmd --query-port=6379/tcp
  • 云服务器安全组配置
    登录云厂商控制台,找到对应实例的安全组,添加入方向规则:端口6379、协议TCP、授权来源为应用服务器IP(或0.0.0.0/0,不推荐生产环境);
  • 网络连通性测试
    在SpringBoot应用服务器执行telnet [Redis IP] 6379nc -zv [Redis IP] 6379,能连通说明端口开放,否则需排查防火墙/安全组。

三、客户端与连接池配置错误

1. Lettuce客户端线程安全与连接泄漏

错误现象

Caused by: io.lettuce.core.RedisException: Cannot retrieve initial cluster partitions from initial URIs [RedisURI [host='192.168.1.200', port=6379]]
# 或
Pool is exhausted and no new connections are allowed

错误原因

  • Lettuce默认使用共享连接(SharedConnection),在高并发或集群环境下可能出现线程安全问题,导致连接失败;
  • 连接池参数配置不合理(如max-active过小、max-wait设置为0导致无限等待),导致连接耗尽;
  • Lettuce客户端未启用连接池(SpringBoot 2.x默认启用,但手动配置时可能遗漏lettuce.pool节点)。

解决方案

  • 优化Lettuce连接池配置(避免连接耗尽):
    spring:
      redis:
        lettuce:
          pool:
            max-active: 16    # 根据业务调整,建议为CPU核心数*2+1
            max-idle: 8       # 空闲连接数不宜过大,避免资源浪费
            min-idle: 4       # 保留最小空闲连接,减少创建连接开销
            max-wait: 3000    # 等待3秒,超时抛出异常,避免阻塞线程
          shutdown-timeout: 2000 # 关闭客户端时的超时时间(毫秒)
  • 启用Lettuce集群模式(若使用Redis集群)
    @Configuration
    public class RedisConfig {
        @Bean
        public RedisConnectionFactory redisConnectionFactory(RedisProperties properties) {
            RedisClusterConfiguration clusterConfig = new RedisClusterConfiguration(properties.getCluster().getNodes());
            clusterConfig.setMaxRedirects(properties.getCluster().getMaxRedirects());
            // 配置Lettuce连接池
            LettucePoolConfiguration poolConfig = LettucePoolConfiguration.builder()
                    .maxActive(properties.getLettuce().getPool().getMaxActive())
                    .maxIdle(properties.getLettuce().getPool().getMaxIdle())
                    .minIdle(properties.getLettuce().getPool().getMinIdle())
                    .maxWait(properties.getLettuce().getPool().getMaxWait())
                    .build();
            return new LettuceConnectionFactory(clusterConfig, poolConfig);
        }
    }
  • 若仍存在线程安全问题,切换为Jedis客户端(Jedis为线程不安全,但通过连接池管理可避免问题)。

2. Jedis连接池初始化失败

错误现象

Caused by: redis.clients.jedis.exceptions.JedisException: Could not get a resource from the pool
# 或
java.lang.IllegalArgumentException: Invalid maxTotal value: -1

错误原因

  • Jedis连接池参数配置错误(如max-active设为负数、max-idle大于max-active);
  • 未引入Jedis依赖却配置了spring.redis.jedis节点,导致Bean初始化失败;
  • Jedis版本与SpringBoot版本不兼容(如SpringBoot 3.x需Jedis 4.x+,否则出现类不兼容)。

解决方案

  • 规范Jedis配置
    spring:
      redis:
        jedis:
          pool:
            max-active: 16    # 必须为正数,默认8
            max-idle: 8       # 不能大于max-active
            min-idle: 4
            max-wait: 3000    # 不能为负数(-1表示无限制,不推荐)
  • 确保Jedis依赖版本兼容:SpringBoot 2.x推荐Jedis 3.x,SpringBoot 3.x推荐Jedis 4.x+;
  • 排查连接池耗尽问题:通过JedisPool.getNumActive()JedisPool.getNumIdle()监控连接池状态,若numActive长期等于max-active,需增大max-active或优化业务代码(避免长连接占用)。

四、序列化与自定义配置错误

1. 序列化方式不兼容导致初始化失败

错误现象

Caused by: org.springframework.data.redis.serializer.SerializationException: Cannot serialize; nested exception is org.springframework.core.serializer.support.SerializationFailedException
# 或
java.io.NotSerializableException: com.example.demo.entity.User

错误原因

  • SpringBoot默认使用JdkSerializationRedisSerializer,要求存储的对象必须实现Serializable接口,否则序列化失败;
  • 自定义序列化器(如Jackson2JsonRedisSerializer)时,未正确配置ObjectMapper,导致序列化逻辑异常;
  • 序列化器与Redis中已存储的数据格式不兼容(如原用JDK序列化,后改为JSON序列化,启动时读取旧数据报错)。

解决方案

  • 方案1:实现Serializable接口(快速解决,适用于简单场景):
    public class User implements Serializable { // 必须实现该接口
        private Long id;
        private String name;
        // getter/setter
    }
  • 方案2:自定义JSON序列化器(推荐,兼容性更强):
    @Configuration
    public class RedisConfig {
        @Bean
        public RedisTemplate<String, Object> redisTemplate(RedisConnectionFactory factory) {
            RedisTemplate<String, Object> template = new RedisTemplate<>();
            template.setConnectionFactory(factory);
            // 配置Jackson2JsonRedisSerializer序列化器
            Jackson2JsonRedisSerializer<Object> serializer = new Jackson2JsonRedisSerializer<>(Object.class);
            ObjectMapper mapper = new ObjectMapper();
            // 开启JSON字段名称驼峰命名与Java属性映射
            mapper.setPropertyNamingStrategy(PropertyNamingStrategies.SNAKE_CASE);
            // 序列化时包含类信息(避免反序列化时类型转换异常)
            mapper.activateDefaultTyping(LaissezFaireSubTypeValidator.instance, ObjectMapper.DefaultTyping.NON_FINAL);
            // 忽略未知字段(提高兼容性)
            mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
            serializer.setObjectMapper(mapper);
            // 设置key和value的序列化方式
            template.setKeySerializer(new StringRedisSerializer()); // key用String序列化(推荐)
            template.setValueSerializer(serializer); // value用JSON序列化
            template.setHashKeySerializer(new StringRedisSerializer());
            template.setHashValueSerializer(serializer);
            template.afterPropertiesSet(); // 初始化配置
            return template;
        }
    }
  • 若Redis中已有旧数据(JDK序列化格式),需先清理旧数据或兼容处理,避免启动时读取报错。

2. 自定义RedisTemplate导致Bean冲突

错误现象

Caused by: org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type 'org.springframework.data.redis.core.RedisTemplate' available: expected single matching bean but found 2

错误原因

  • 自定义了RedisTemplate Bean,但未指定@Primary,导致SpringBoot自动配置的RedisTemplate与自定义Bean冲突;
  • 多个配置类中定义了RedisTemplate,且未区分Bean名称或未指定@Primary

解决方案

  • 在自定义RedisTemplate上添加@Primary,优先注入自定义Bean:
    @Configuration
    public class RedisConfig {
        @Primary // 关键:解决Bean冲突
        @Bean
        public RedisTemplate<String, Object> redisTemplate(RedisConnectionFactory factory) {
            // 自定义配置逻辑...
        }
    }
  • 若需多个RedisTemplate,通过@Qualifier指定Bean名称区分:
    // 自定义两个RedisTemplate,指定不同名称
    @Bean("jsonRedisTemplate")
    public RedisTemplate<String, Object> jsonRedisTemplate(RedisConnectionFactory factory) { /* ... */ }
    @Bean("jdkRedisTemplate")
    public RedisTemplate<String, Object> jdkRedisTemplate(RedisConnectionFactory factory) { /* ... */ }
    // 使用时指定Bean名称
    @Autowired
    @Qualifier("jsonRedisTemplate")
    private RedisTemplate<String, Object> redisTemplate;

五、集群/哨兵模式配置错误

1. Redis集群节点配置错误

错误现象

Caused by: io.lettuce.core.cluster.RedisClusterException: Cannot determine a partition for slot 1234
# 或
No reachable node in cluster

错误原因

  • spring.redis.cluster.nodes配置错误(如节点IP/端口错误、缺少主节点、节点间未建立集群关系);
  • 集群节点未全部启动或部分节点故障,导致无法获取集群分区信息;
  • 未配置spring.redis.cluster.max-redirects(集群重定向次数,默认3),导致跨节点访问失败。

解决方案

  • 正确配置集群节点
    spring:
      redis:
        cluster:
          nodes: 192.168.1.101:6379,192.168.1.102:6379,192.168.1.103:6379 # 所有主从节点IP:端口
          max-redirects: 3 # 集群重定向次数,默认3,无需修改
        password: 123456 # 集群所有节点密码需一致
  • 验证集群状态:在Redis任意节点执行redis-cli cluster info,查看cluster_state:ok说明集群正常;执行cluster nodes确认所有节点已加入集群;
  • 确保集群节点间网络互通(集群节点需开放gossip协议端口,默认6379+10000=16379)。

2. Redis哨兵模式配置错误

错误现象

Caused by: org.springframework.data.redis.connection.RedisConnectionFailureException: Cannot get Jedis connection; nested exception is redis.clients.jedis.exceptions.JedisConnectionException: Could not get a resource from the pool
# 或
Failed to connect to any sentinel.

错误原因

  • 哨兵节点IP/端口配置错误,或哨兵服务未启动;
  • 未指定哨兵监控的主节点名称(spring.redis.sentinel.master),导致无法发现主节点;
  • 哨兵集群中多数节点故障,无法完成主从切换检测。

解决方案

  • 哨兵模式标准配置
    spring:
      redis:
        sentinel:
          master: mymaster # 哨兵监控的主节点名称(需与Redis哨兵配置一致)
          nodes: 192.168.1.104:26379,192.168.1.105:26379 # 所有哨兵节点IP:端口(默认26379)
        password: 123456 # 主从节点密码需一致
        timeout: 5000
  • 验证哨兵状态:执行redis-cli -h [哨兵IP] -p 26379 sentinel master mymaster,查看主节点状态是否正常;
  • 确保哨兵节点与主从节点网络互通,且哨兵配置文件(sentinel.conf)中protected-mode已关闭或配置了绑定IP。

六、其他特殊场景错误

1. Redis内存满导致启动时写入失败

错误现象

Caused by: io.lettuce.core.RedisCommandExecutionException: OOM command not allowed when used memory > 'maxmemory'

错误原因

Redis启用了maxmemory限制(默认无限制,生产环境常配置),且内存已达上限,maxmemory-policy设为noeviction(默认值),导致无法写入数据。若SpringBoot启动时需初始化缓存数据(如@PostConstruct中执行redisTemplate.opsForValue().set(...)),会因写入失败导致启动报错。

解决方案

  • 临时解决方案:清理Redis缓存(redis-cli flushall),释放内存;
  • 长期解决方案:
    1. 增大Redismaxmemory配置(redis.confmaxmemory 4gb);
    2. 修改内存淘汰策略(maxmemory-policy allkeys-lru,优先淘汰最近最少使用的key);
    3. 优化业务缓存逻辑,避免存储大体积数据或设置合理的过期时间(expire)。

2. SpringBoot启动顺序导致Redis依赖未就绪

错误现象

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'redisTemplate' defined in class path resource [com/example/demo/config/RedisConfig.class]: Bean instantiation via factory method failed

错误原因

  • 自定义组件(如缓存管理器、业务服务)在启动时依赖RedisTemplate,但RedisTemplate尚未初始化完成;
  • 使用@Cacheable等缓存注解时,SpringBoot自动初始化缓存管理器,但Redis连接未就绪,导致启动失败。

解决方案

  • 延迟初始化依赖Redis的Bean:在Bean上添加@Lazy,避免启动时立即初始化;
  • 配置缓存管理器延迟初始化:
    spring:
      cache:
        type: redis
        redis:
          cache-null-values: false
        enable: false # 关闭自动缓存初始化,在业务启动后手动启用
  • 确保Redis连接池初始化在依赖Bean之前:通过@DependsOn("redisTemplate")指定Bean依赖顺序。

七、排查思路与最佳实践

1. 快速排查四步法

  1. 日志定位:优先查看SpringBoot启动日志的Caused by异常栈,聚焦核心错误信息(如“Connection refused”→服务未启动,“NOAUTH”→密码错误);
  2. 服务可达性验证:用redis-clitelnetnc工具测试Redis服务是否可连接(先解决网络层问题);
  3. 配置校验:对照标准配置模板,检查依赖、配置项拼写、连接池参数、序列化配置是否正确;
  4. 版本兼容性验证:确认SpringBoot、spring-data-redis、Redis客户端、Redis服务端版本是否兼容(参考Spring官方兼容性文档)。

2. 生产环境最佳实践

  • 依赖管理:使用SpringBoot Starter统一管理依赖,避免手动指定版本;
  • 配置规范:敏感信息(密码、IP)通过配置中心或环境变量注入,避免明文;
  • 连接池优化:根据业务并发量调整max-activemax-wait等参数,定期监控连接池状态;
  • 序列化选择:推荐使用JSON序列化(Jackson2JsonRedisSerializer),提高跨语言兼容性;
  • 高可用部署:生产环境采用Redis集群/哨兵模式,避免单点故障;
  • 监控告警:集成Prometheus+Grafana监控Redis连接数、内存使用率、命中率,设置告警阈值;
  • 容错处理:配置Redis连接超时重试机制,避免因短暂网络波动导致启动失败:
    @Bean
    public RedisConnectionFactory redisConnectionFactory(RedisProperties properties) {
        LettuceClientConfiguration clientConfig = LettuceClientConfiguration.builder()
                .commandTimeout(Duration.ofMillis(properties.getTimeout()))
                .retryPolicy(RetryPolicies.retryOnConnectionFailure(3)) // 重试3次
                .build();
        RedisStandaloneConfiguration config = new RedisStandaloneConfiguration(
                properties.getHost(), properties.getPort());
        config.setPassword(RedisPassword.of(properties.getPassword()));
        return new LettuceConnectionFactory(config, clientConfig);
    }
    

总结

SpringBoot整合Redis启动失败的核心原因集中在连接层(服务未启动、端口/防火墙拦截、密码错误)、配置层(依赖缺失、参数错误、序列化不兼容)、客户端层(连接池配置、版本冲突) 三类。解决问题的关键是“先定位异常类型,再逐层排查”——优先解决网络连通性和基础配置问题,再处理序列化、自定义配置等复杂场景。

遵循最佳实践(如规范依赖、优化连接池、使用JSON序列化、高可用部署)可大幅降低启动失败概率。生产环境需额外关注安全(密码加密、IP白名单)、监控和容错能力,确保Redis服务稳定支撑业务。

到此这篇关于SpringBoot Redis 启动失败深度剖析与标准化解决方案的文章就介绍到这了,更多相关SpringBoot Redis 启动失败内容请搜索脚本之家以前的文章或继续浏览下面的相关文章希望大家以后多多支持脚本之家!

相关文章

  • SpringBoot 如何使用Dataway配置数据查询接口

    SpringBoot 如何使用Dataway配置数据查询接口

    这篇文章主要介绍了SpringBoot 如何使用Dataway配置数据查询接口,具有很好的参考价值,希望对大家有所帮助。如有错误或未考虑完全的地方,望不吝赐教
    2021-11-11
  • Java序列化的原理分析及解决

    Java序列化的原理分析及解决

    文章介绍了Java中的序列化机制,包括Serializable和Externalizable接口的区别,以及serialVersionUID的作用,Serializable接口可以序列化的所有子类型本身都是可序列化的,如果要序列化的类有父类,父类也应该实现Serializable接口
    2024-11-11
  • SpringBoot集成MyBatis实现SQL拦截器的实战指南

    SpringBoot集成MyBatis实现SQL拦截器的实战指南

    这篇文章主要为大家详细介绍了SpringBoot集成MyBatis实现SQL拦截器的相关知识,文中的示例代码讲解详细,有需要的小伙伴可以参考一下
    2025-07-07
  • Java基于LoadingCache实现本地缓存的示例代码

    Java基于LoadingCache实现本地缓存的示例代码

    本文主要介绍了Java基于LoadingCache实现本地缓存的示例代码,文中通过示例代码介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
    2022-01-01
  • Java编写日历表的3种方式

    Java编写日历表的3种方式

    这篇文章主要为大家详细介绍了Java编写日历表的3种方式,文中示例代码介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
    2021-08-08
  • Java识别和处理HTML标签内容的常用方法

    Java识别和处理HTML标签内容的常用方法

    这篇文章总结了识别和处理HTML的几种方法:推荐使用Jsoup处理复杂结构,因其功能强大且API友好;避免正则表达式和XML解析器处理嵌套标签;需清理用户输入中的潜在安全风险,并注意字符编码问题,需要的朋友可以参考下
    2025-07-07
  • Spring动态注册多数据源的实现方法

    Spring动态注册多数据源的实现方法

    这篇文章主要介绍了Spring动态注册多数据源的实现方法,小编觉的挺不错的,现分享到脚本之家平台,需要的朋友可以参考下
    2018-01-01
  • spring boot加载第三方jar包的配置文件的方法

    spring boot加载第三方jar包的配置文件的方法

    本篇文章主要介绍了spring boot加载第三方jar包的配置文件的方法,详细的介绍了spring boot jar包配置文件的方法,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
    2017-10-10
  • 详解SpringBoot统一响应体解决方案

    详解SpringBoot统一响应体解决方案

    这篇文章主要介绍了详解SpringBoot统一响应体解决方案,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
    2019-07-07
  • spring data jpa 创建方法名进行简单查询方式

    spring data jpa 创建方法名进行简单查询方式

    这篇文章主要介绍了spring data jpa 创建方法名进行简单查询方式,具有很好的参考价值,希望对大家有所帮助。如有错误或未考虑完全的地方,望不吝赐教
    2022-02-02

最新评论