本文介绍了运行示例keycloak spring-boot应用程序时出现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正尝试从以下位置运行示例应用程序:

I'm trying to run example app from:

https://github.com/keycloak/keycloak-quickstarts/tree/latest/app-springboot

我遇到错误:

***************************
APPLICATION FAILED TO START
***************************

Description:

Parameter 1 of method setKeycloakSpringBootProperties in org.keycloak.adapters.springboot.KeycloakBaseSpringBootConfiguration required a bean of type 'org.keycloak.adapters.springboot.KeycloakSpringBootConfigResolver' that could not be found.


Action:

Consider defining a bean of type 'org.keycloak.adapters.springboot.KeycloakSpringBootConfigResolver' in your configuration.


Process finished with exit code 1

推荐答案

目前我没有解决方案,但是我可以看到几个月前在Keycloak Jira上已经注册了完全相同的问题: https://issues.jboss.org/browse/KEYCLOAK-10595 .该问题似乎是由此PR附带的代码引起的: https://github.com/keycloak /keycloak/pull/6075 .

I don't have a solution at the moment, but I can see that the exact same issue has been registered on the Keycloak Jira a couple of months ago: https://issues.jboss.org/browse/KEYCLOAK-10595. The problem seems to be caused by the code delivered with this PR: https://github.com/keycloak/keycloak/pull/6075.

PR的作者以这种方式描述了问题:唯一剩下的问题是,解析器通常包含在使用KeycloakAutoConfiguration的配置中(在我的示例中为SharedConfiguration),因此您在创建配置时尝试访问Bean.这可以通过移动解析器来解决. Bean放入另一个必须在KeycloakAutoConfiguration之前加载的配置."(来源: https://issues.jboss.org/browse/KEYCLOAK-10334?focusedCommentId=13738518&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-13738518 )

The author of the PR described the problem in this way:"The only remaining problem is, that the resolver is usually contained in the configuration using the KeycloakAutoConfiguration (in my example the SharedConfiguration) so you are trying to access the bean while the configuration is stil being created. This can be solved by moving the resolver bean into another configuration which has to be loaded before the KeycloakAutoConfiguration."(source: https://issues.jboss.org/browse/KEYCLOAK-10334?focusedCommentId=13738518&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-13738518)

更新(OLD)

关于Keycloak Jira( https://issues.jboss.org/browse/KEYCLOAK-11282 ),建议采用临时解决方法.

On the issue from the Keycloak Jira (https://issues.jboss.org/browse/KEYCLOAK-11282), a temporary workaround has been suggested.

@Configuration
public class MyKeycloakSpringBootConfigResolver extends KeycloakSpringBootConfigResolver {
    private final KeycloakDeployment keycloakDeployment;

    public MyKeycloakSpringBootConfigResolver(KeycloakSpringBootProperties properties) {
        keycloakDeployment = KeycloakDeploymentBuilder.build(properties);
    }

    @Override
    public KeycloakDeployment resolve(HttpFacade.Request facade) {
        return keycloakDeployment;
    }
}


最新更新

解决问题的更简单方法是在单独的配置类中声明KeycloakSpringBootConfigResolver.此选项将解决Spring Boot和Spring Security的问题.

A simpler way to solve the problem is to declare a KeycloakSpringBootConfigResolver in a separate configuration class. This option will fix issues with both Spring Boot and Spring Security.

@Configuration
public class KeycloakConfig {

    @Bean
    public KeycloakSpringBootConfigResolver keycloakConfigResolver() {
        return new KeycloakSpringBootConfigResolver();
    }
}

这篇关于运行示例keycloak spring-boot应用程序时出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-20 14:52