fix: 修复 RedisCenter 循环依赖导致的启动失败(BeanCurrentlyInCreationException)#388
Open
Hungerdream wants to merge 1 commit into
Open
fix: 修复 RedisCenter 循环依赖导致的启动失败(BeanCurrentlyInCreationException)#388Hungerdream wants to merge 1 commit into
Hungerdream wants to merge 1 commit into
Conversation
RedisCenterImpl 含 @async 方法,导致与 MachineCenterImpl / AppScrollRestartServiceImpl 的循环依赖无法用 Spring 早期引用机制消解。 在两个类的 RedisCenter 字段注入处加 @lazy,注入懒加载代理占位符打破循环。 关联 sohutv#387
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
关联 Issue
问题
应用启动失败,抛出:
根因
RedisCenterImpl上存在@Async注解的方法(如findInstancePatternKeys,返回java.util.concurrent.Future,见RedisCenterImpl.java:912)。@Async要求 Spring 在 bean 完全初始化之后才为其生成异步代理,导致与MachineCenterImpl/AppScrollRestartServiceImpl的循环依赖无法用 Spring 的“早期引用(early reference)”机制消解。修复
在
MachineCenterImpl和AppScrollRestartServiceImpl对RedisCenter的字段注入处加@Lazy,注入懒加载代理占位符以打破循环。修改文件:
cachecloud-web/src/main/java/com/sohu/cache/machine/impl/MachineCenterImpl.javacachecloud-web/src/main/java/com/sohu/cache/web/service/impl/AppScrollRestartServiceImpl.java验证
已本地编译并部署验证(profile=open),应用启动正常,不再抛出循环依赖异常。