Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/spring-boot/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring boot 无法将属性clientid绑定到OAuth2Client属性$Registration_Spring Boot_Spring Security Oauth2 - Fatal编程技术网

Spring boot 无法将属性clientid绑定到OAuth2Client属性$Registration

Spring boot 无法将属性clientid绑定到OAuth2Client属性$Registration,spring-boot,spring-security-oauth2,Spring Boot,Spring Security Oauth2,我正在开发一个spring启动应用程序,以便与另一个安全API通信。 为此,我实现了一个具有以下属性的OAuth2RestTemplate,但在运行应用程序时失败了 @Configuration @EnableOAuth2Client class RestTemplateConfiguration { @Bean @ConfigurationProperties("oauth2") public OAuth2ProtectedResourceDetails oAuth2

我正在开发一个spring启动应用程序,以便与另一个安全API通信。 为此,我实现了一个具有以下属性的OAuth2RestTemplate,但在运行应用程序时失败了

@Configuration
@EnableOAuth2Client
class RestTemplateConfiguration {

    @Bean
    @ConfigurationProperties("oauth2")
    public OAuth2ProtectedResourceDetails oAuth2ProtectedResourceDetails() {
        return new ClientCredentialsResourceDetails();
    }

    @Bean
    public OAuth2RestTemplate oAuth2RestTemplate(
            @Qualifier("oAuth2ProtectedResourceDetails") OAuth2ProtectedResourceDetails oAuth2ProtectedResourceDetails) {
        return new OAuth2RestTemplate(oAuth2ProtectedResourceDetails);
    }

}
应用程序属性

spring:
  security:
    oauth2:
      client:
        registration:
            clientId: xxxxxxxxxxxxxxxxxx
            clientSecret: xxxxxxxxxxxxxxxxx
            accessTokenUri: https://xxxxxx/oauth2/access_token
            scope: openid profile xxxxxxxxxxx
            authorizationGrantType: client_credentials
运行代码时得到的异常

Failed to bind properties under 'spring.security.oauth2.client.registration.clientid' to org.springframework.boot.autoconfigure.security.oauth2.client.OAuth2ClientProperties$Registration:

我认为问题就在这里

  security:
    oauth2:
      client:
        registration:
          mb:
            client-name: mb
            client-id: ui
            client-secret: secret
            authorization-grant-type: authorization_code
            redirect-uri: http:localhost:8084/ui/login/oauth2/code/
            scope: openId
            client-authentication-method: basic
        provider:
          mb:
            token-uri: http://localhost:8181/oauth/token
            authorization-uri: http:localhost:8181/oauth/authorize
            user-info-uri: http:localhost:8181/oauth/userinfo
            user-name-attribute: name