记录一些遇见的bug——项目启动报错Parameter 1 of constructor in com.example.filter.SimpleGlobalFilter required a bea
报错截图:错误代码:二、问题原因上午运行得好好的代码,啥都没改下午程序突然就挂了,死活起不来,就报如图所示错误。让程序猿忍不住怀疑人生,开始相信运行程序之前需要洗手焚香的传说…重点是啥都没改。。然后原因是,本微服务(gateway)中引用了自己写的工具类commons-util工具类,如图所示:而commons-util工具类中引用了redis依赖没有排除,与gateway微服务中引用的redis
·
记录一些遇见的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.ReactiveRedisConnectionFactory
Action:
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不参与打包。
再次运行,程序顺利启动。
更多推荐
已为社区贡献1条内容
所有评论(0)