由于 UnsatisfiedDependencyException,带有 Okta 应用程序的 JHipster 无法启动
JHipster with Okta Application Failed to Start due to UnsatisfiedDependencyException
添加 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.
如有任何建议,我们将不胜感激。
好的 - 明白了。我必须创建 ~/.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 的指示进行操作。
谢谢马特·雷布尔!
排灯节快乐。
添加 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.
如有任何建议,我们将不胜感激。
好的 - 明白了。我必须创建 ~/.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 的指示进行操作。
谢谢马特·雷布尔!
排灯节快乐。