Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
18700405761 opened this issue May 29, 2024 · 0 comments

Comments

@18700405761
Copy link

本地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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant