yangzongzhuan / RuoYi

:tada: (RuoYi)官方仓库 基于SpringBoot的权限管理系统 易读易懂、界面简洁美观。 核心技术采用Spring、MyBatis、Shiro没有任何其它重度依赖。直接运行即可用
http://ruoyi.vip
MIT License
6.37k stars 1.89k forks source link

Spring Boot 自动配置了一个 redisTemplate,但你的配置类 RedisConfig 中也尝试定义了一个,导致冲突 #240

Open 18700405761 opened 5 months ago

18700405761 commented 5 months ago

本地idea连接nacos配置中心启动gateway服务正常,打包后用docker启动gateway报错,Spring Boot 自动配置了一个 redisTemplate,但你的配置类 RedisConfig 中也尝试定义了一个,导致冲突

aId[ruoyi-gateway] & group[DEFAULT_GROUP] ruoyi-gateway | 03:33:38.384 [main] WARN c.a.c.n.c.NacosPropertySourceBuilder - [loadNacosData,87] - Ignore the empty nacos configuration and get it based on dataId[ruoyi-gateway.yml] & group[DEFAULT_GROUP] ruoyi-gateway | 03:33:38.449 [main] INFO c.r.g.RuoYiGatewayApplication - [logStartupProfileInfo,646] - The following 1 profile is active: "dev" ruoyi-gateway | 03:33:40.817 [main] WARN o.s.b.w.r.c.AnnotationConfigReactiveWebServerApplicationContext - [refresh,591] - Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.support.BeanDefinitionOverrideException: Invalid bean definition with name 'redisTemplate' defined in class path resource [com/ruoyi/common/redis/configure/RedisConfig.class]: Cannot register bean definition [Root bean: class [null]; scope=; abstract=false; lazyInit=null; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=com.ruoyi.common.redis.configure.RedisConfig; factoryMethodName=redisTemplate; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [com/ruoyi/common/redis/configure/RedisConfig.class]] for bean 'redisTemplate': There is already [Root bean: class [null]; scope=; abstract=false; lazyInit=null; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration; factoryMethodName=redisTemplate; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/boot/autoconfigure/data/redis/RedisAutoConfiguration.class]] bound. ruoyi-gateway | 03:33:41.022 [main] ERROR o.s.b.d.LoggingFailureAnalysisReporter - [report,40] - ruoyi-gateway | ruoyi-gateway | ruoyi-gateway | APPLICATION FAILED TO START ruoyi-gateway | ruoyi-gateway | ruoyi-gateway | Description: ruoyi-gateway | ruoyi-gateway | The bean 'redisTemplate', defined in class path resource [com/ruoyi/common/redis/configure/RedisConfig.class], could not be registered. A bean with that name has already been defined in class path resource [org/springframework/boot/autoconfigure/data/redis/RedisAutoConfiguration.class] and overriding is disabled. ruoyi-gateway | ruoyi-gateway | Action: ruoyi-gateway | ruoyi-gateway | Consider renaming one of the beans or enabling overriding by setting spring.main.allow-bean-definition-overriding=true