Spring Boot 2.6.x 似乎引入了一些更改,导致之前与 Keycloak 的集成出现循环引用,从而阻止应用程序启动;它可以在当前的 2.5.x 版本中正常工作并启动。
\n明确地说,通过在spring-boot-starter-parent中将<version> 标记值从 2.5.7 更改为 2.6.1 之外的任何内容,都会出现下面详细说明的错误/消息。
\n当然,预期的行为是应用程序正常启动,并且像以前一样使用 Keycloak 进行保护。
\n实际的消息是:
\n***************************\nAPPLICATION FAILED TO START\n***************************\n\nDescription:\n\nThe dependencies of some of the beans in the application context form a cycle:\n\n\xe2\x94\x8c\xe2\x94\x80\xe2\x94\x80->\xe2\x94\x80\xe2\x94\x80\xe2\x94\x90\n| keycloakSecurityConfig (field private org.keycloak.adapters.KeycloakConfigResolver org.keycloak.adapters.springsecurity.config.KeycloakWebSecurityConfigurerAdapter.keycloakConfigResolver)\n\xe2\x94\x94\xe2\x94\x80\xe2\x94\x80<-\xe2\x94\x80\xe2\x94\x80\xe2\x94\x98\nRun Code Online (Sandbox Code Playgroud)\n完整的堆栈跟踪:
\n2021-11-30 12:49:07.308 DEBUG 7 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter : Application failed to start due to an exception\n\norg.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name \'keycloakSecurityConfig\': Requested bean is currently in creation: Is …Run Code Online (Sandbox Code Playgroud)