记录一些遇见的bug——项目启动报错Parameter 1 of constructor in com.example.filter.SimpleGlobalFilter required a bea

本文主要是介绍记录一些遇见的bug——项目启动报错Parameter 1 of constructor in com.example.filter.SimpleGlobalFilter required a bea,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

记录一些遇见的bug——项目启动报错Parameter 1 of constructor in com.example.filter.SimpleGlobalFilter required a bean of type 'org.springframework.data.redis.core.ReactiveStringRedisTemplate' that could not be found.

  • 一、问题描述
  • 二、问题原因
  • 三、解决方案

)

一、问题描述

报错截图:
在这里插入图片描述
错误代码:

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2022-09-19 19:49:55.431 ERROR 7816 --- [           main] o.s.b.d.LoggingFailureAnalysisReporter   : ***************************
APPLICATION FAILED TO START
***************************Description:Parameter 1 of constructor in com.example.filter.SimpleGlobalFilter required a bean of type 'org.springframework.data.redis.core.ReactiveStringRedisTemplate' that could not be found.The following candidates were found but could not be injected:- Bean method 'reactiveStringRedisTemplate' in 'RedisReactiveAutoConfiguration' not loaded because @ConditionalOnBean (types: org.springframework.data.redis.connection.ReactiveRedisConnectionFactory; SearchStrategy: all) did not find any beans of type org.springframework.data.redis.connection.ReactiveRedisConnectionFactoryAction:Consider revisiting the entries above or defining a bean of type 'org.springframework.data.redis.core.ReactiveStringRedisTemplate' in your configuration.Process finished with exit code 1

二、问题原因

上午运行得好好的代码,啥都没改下午程序突然就挂了,死活起不来,就报如图所示错误。
让程序猿忍不住怀疑人生,开始相信运行程序之前需要洗手焚香的传说…

重点是啥都没改。。

然后原因是,本微服务(gateway)中引用了自己写的工具类commons-util工具类,如图所示:
在这里插入图片描述
而commons-util工具类中引用了redis依赖没有排除,与gateway微服务中引用的redis-reactive依赖造成冲突。
有时候A依赖覆盖B依赖,这时候程序可以正常运行。
有时候B依赖占上风覆盖A依赖,这个时候程序跑不起来。
所以造成了啥都没动程序挂掉起不来的灵异事件。。
在这里插入图片描述

在这里插入图片描述

三、解决方案

为工具类commons-util中的依赖加上provide的作用域,如图所示:
使工具类中的redis不参与打包。
在这里插入图片描述
再次运行,程序顺利启动。

这篇关于记录一些遇见的bug——项目启动报错Parameter 1 of constructor in com.example.filter.SimpleGlobalFilter required a bea的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/261570

相关文章

基于 Cursor 开发 Spring Boot 项目详细攻略

《基于Cursor开发SpringBoot项目详细攻略》Cursor是集成GPT4、Claude3.5等LLM的VSCode类AI编程工具,支持SpringBoot项目开发全流程,涵盖环境配... 目录cursor是什么?基于 Cursor 开发 Spring Boot 项目完整指南1. 环境准备2. 创建

Three.js构建一个 3D 商品展示空间完整实战项目

《Three.js构建一个3D商品展示空间完整实战项目》Three.js是一个强大的JavaScript库,专用于在Web浏览器中创建3D图形,:本文主要介绍Three.js构建一个3D商品展... 目录引言项目核心技术1. 项目架构与资源组织2. 多模型切换、交互热点绑定3. 移动端适配与帧率优化4. 可

sky-take-out项目中Redis的使用示例详解

《sky-take-out项目中Redis的使用示例详解》SpringCache是Spring的缓存抽象层,通过注解简化缓存管理,支持Redis等提供者,适用于方法结果缓存、更新和删除操作,但无法实现... 目录Spring Cache主要特性核心注解1.@Cacheable2.@CachePut3.@Ca

解决升级JDK报错:module java.base does not“opens java.lang.reflect“to unnamed module问题

《解决升级JDK报错:modulejava.basedoesnot“opensjava.lang.reflect“tounnamedmodule问题》SpringBoot启动错误源于Jav... 目录问题描述原因分析解决方案总结问题描述启动sprintboot时报以下错误原因分析编程异js常是由Ja

SpringBoot通过main方法启动web项目实践

《SpringBoot通过main方法启动web项目实践》SpringBoot通过SpringApplication.run()启动Web项目,自动推断应用类型,加载初始化器与监听器,配置Spring... 目录1. 启动入口:SpringApplication.run()2. SpringApplicat

解决Nginx启动报错Job for nginx.service failed because the control process exited with error code问题

《解决Nginx启动报错Jobfornginx.servicefailedbecausethecontrolprocessexitedwitherrorcode问题》Nginx启... 目录一、报错如下二、解决原因三、解决方式总结一、报错如下Job for nginx.service failed bec

Python中的filter() 函数的工作原理及应用技巧

《Python中的filter()函数的工作原理及应用技巧》Python的filter()函数用于筛选序列元素,返回迭代器,适合函数式编程,相比列表推导式,内存更优,尤其适用于大数据集,结合lamb... 目录前言一、基本概念基本语法二、使用方式1. 使用 lambda 函数2. 使用普通函数3. 使用 N

Springboot项目构建时各种依赖详细介绍与依赖关系说明详解

《Springboot项目构建时各种依赖详细介绍与依赖关系说明详解》SpringBoot通过spring-boot-dependencies统一依赖版本管理,spring-boot-starter-w... 目录一、spring-boot-dependencies1.简介2. 内容概览3.核心内容结构4.

java -jar example.jar 产生的日志输出到指定文件的方法

《java-jarexample.jar产生的日志输出到指定文件的方法》这篇文章给大家介绍java-jarexample.jar产生的日志输出到指定文件的方法,本文给大家介绍的非常详细,对大家的... 目录怎么让 Java -jar example.jar 产生的日志输出到指定文件一、方法1:使用重定向1、

Java报错:org.springframework.beans.factory.BeanCreationException的五种解决方法

《Java报错:org.springframework.beans.factory.BeanCreationException的五种解决方法》本文解析Spring框架中BeanCreationExce... 目录引言一、问题描述1.1 报错示例假设我们有一个简单的Java类,代表一个用户信息的实体类:然后,