【问题标题】:JHipster with Okta Application Failed to Start due to UnsatisfiedDependencyException由于 UnsatisfiedDependencyException,带有 Okta 应用程序的 JHipster 无法启动
【发布时间】:2020-11-14 03:33:25
【问题描述】:

添加 OKTA 配置后启动 JHipster Gateway 应用程序时出现以下错误:

$ cd saathratrigateway
$ ./mvnw

...
2020-11-13 22:31:16.278  WARN 80043 --- [  restartedMain] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'authorizationHeaderUtil' defined in file [/Users/amar/workspace/saathratri-app-holder/saathratrigateway/target/classes/com/saathratri/security/oauth2/AuthorizationHeaderUtil.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'org.springframework.security.oauth2.client.OAuth2AuthorizedClientService' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}
2020-11-13 22:31:16.280 DEBUG 80043 --- [  restartedMain] c.e.c.E.saathratri.domain.Authority      : Close successful.
2020-11-13 22:31:16.281 DEBUG 80043 --- [  restartedMain] c.e.c.E.saathratri.domain.User           : Close successful.
2020-11-13 22:31:16.281 DEBUG 80043 --- [  restartedMain] c.e.c.E.s.domain.User.authorities        : Close successful.
2020-11-13 22:31:16.282 DEBUG 80043 --- [  restartedMain] c.ehcache.core.Ehcache-usersByEmail      : Close successful.
2020-11-13 22:31:16.282 DEBUG 80043 --- [  restartedMain] c.ehcache.core.Ehcache-usersByLogin      : Close successful.
2020-11-13 22:31:16.479 ERROR 80043 --- [  restartedMain] o.s.b.d.LoggingFailureAnalysisReporter   : 

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

Description:

Parameter 0 of constructor in com.saathratri.security.oauth2.AuthorizationHeaderUtil required a bean of type 'org.springframework.security.oauth2.client.OAuth2AuthorizedClientService' that could not be found.

The following candidates were found but could not be injected:
    - Bean method 'authorizedClientService' in 'OAuth2WebSecurityConfiguration' not loaded because @ConditionalOnBean (types: org.springframework.security.oauth2.client.registration.ClientRegistrationRepository; SearchStrategy: all) did not find any beans of type org.springframework.security.oauth2.client.registration.ClientRegistrationRepository


Action:

Consider revisiting the entries above or defining a bean of type 'org.springframework.security.oauth2.client.OAuth2AuthorizedClientService' in your configuration.

任何建议将不胜感激。

【问题讨论】:

    标签: jhipster okta jhipster-gateway


    【解决方案1】:

    好的 - 想通了。我必须创建 ~/.okta.env,然后运行 ​​source ~/.okta.env。见下文....

    $ vi ~/.okta.env
    
    ---
    export SPRING_SECURITY_OAUTH2_CLIENT_PROVIDER_OIDC_ISSUER_URI="https://dev-XXXXXXX.okta.com/oauth2/default"
    export SPRING_SECURITY_OAUTH2_CLIENT_REGISTRATION_OIDC_CLIENT_ID="XXXXXXXXXXXXXXXXXXXX"
    export SPRING_SECURITY_OAUTH2_CLIENT_REGISTRATION_OIDC_CLIENT_SECRET="XXXXXX-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
    export OKTA_OAUTH2_ISSUER="https://dev-XXXXXXX.okta.com/oauth2/default"
    export OKTA_OAUTH2_CLIENT_ID_WEB="XXXXXXXXXXXXXXXXXXXX"
    export OKTA_OAUTH2_CLIENT_SECRET_WEB="XXXXXX-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
    ---
    
    $ source ~/.okta.env
    
    $ cd saathratrigateway
    $ ./mvnw
    
    

    我按照https://developer.okta.com/blog/2018/03/01/develop-microservices-jhipster-oauth 的指示进行操作。

    谢谢马特·雷布尔!

    排灯节快乐。

    【讨论】:

    • 对不起,它可以在没有 sudo 的情况下工作。已修改答案。谢谢!
    • 我很高兴看到你想通了! ?
    猜你喜欢
    • 1970-01-01
    • 2019-04-13
    • 2021-12-25
    • 2011-08-22
    • 1970-01-01
    • 2019-11-17
    • 2019-12-19
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多