2.8版本 启动报redis注入问题

Blade 未结 2 1191
1010602131
1010602131 2021-04-28 08:04

一、该问题的重现步骤是什么?

1. 下载2.8版本

2. 配置好redis、数据库连接

3.启动


二、你期待的结果是什么?实际看到的又是什么?

 期待正常启动

实际看到


Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.

2021-04-28 07:59:49.946 ERROR 15884 --- [           main] o.s.b.d.LoggingFailureAnalysisReporter   : 


***************************

APPLICATION FAILED TO START

***************************


Description:


Parameter 0 of method bladeRedis in org.springblade.core.redis.config.RedisTemplateConfiguration required a bean of type 'org.springframework.data.redis.core.RedisTemplate' that could not be found.


The following candidates were found but could not be injected:

- Bean method 'redisTemplate' in 'RedisTemplateConfiguration' not loaded because @ConditionalOnMissingBean (names: redisTemplate; SearchStrategy: all) found beans named redisTemplate



Action:


Consider revisiting the entries above or defining a bean of type 'org.springframework.data.redis.core.RedisTemplate' in your configuration.


Disconnected from the target VM, address: '127.0.0.1:7071', transport: 'socket'


Process finished with exit code 1

三、你正在使用的是什么产品,什么版本?在什么操作系统上?

  bladex 单体 2.8版本   window8.1环境

四、请提供详细的错误堆栈信息,这很重要。

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.

2021-04-28 07:59:49.946 ERROR 15884 --- [           main] o.s.b.d.LoggingFailureAnalysisReporter   : 


***************************

APPLICATION FAILED TO START

***************************


Description:


Parameter 0 of method bladeRedis in org.springblade.core.redis.config.RedisTemplateConfiguration required a bean of type 'org.springframework.data.redis.core.RedisTemplate' that could not be found.


The following candidates were found but could not be injected:

- Bean method 'redisTemplate' in 'RedisTemplateConfiguration' not loaded because @ConditionalOnMissingBean (names: redisTemplate; SearchStrategy: all) found beans named redisTemplate



Action:


Consider revisiting the entries above or defining a bean of type 'org.springframework.data.redis.core.RedisTemplate' in your configuration.


Disconnected from the target VM, address: '127.0.0.1:7071', transport: 'socket'


Process finished with exit code 1

五、若有更多详细信息,请在下面提供。

2条回答
  •  1010602131
    1010602131 (楼主)
    2021-05-07 09:32

    1. 代码里面没有自己额外实例化redisTemplate,如果不使用BladeRedis 能正常启动,使用就报错

    2.报错信息

    Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'addressEndPointV2': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'bladeRedis' defined in class path resource [org/springblade/core/redis/config/RedisTemplateConfiguration.class]: Unsatisfied dependency expressed through method 'bladeRedis' parameter 0; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'org.springframework.data.redis.core.RedisTemplate' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}


    Parameter 0 of method bladeRedis in org.springblade.core.redis.config.RedisTemplateConfiguration required a bean of type 'org.springframework.data.redis.core.RedisTemplate' that could not be found.

    The following candidates were found but could not be injected:

    - Bean method 'redisTemplate' in 'RedisTemplateConfiguration' not loaded because @ConditionalOnMissingBean (names: redisTemplate; SearchStrategy: all) found beans named redisTemplate


    启动过程中对 AddressEndPointV2类进行实例化失败,里面用到了bladeRedis注入失败,原因是对AddressEndPointV2进行实例化的优先于bladeRedis的实例化导致 无法注入

    image.png

提交回复