Thursday, June 9, 2022

Spring Beans not Instantiating

I had not seen this error before:

No qualifying bean of type 'org.springframework.security.oauth2.client.registration.ClientRegistrationRepository' available

It took a little bit of research to find that if you do not have your application.yaml with the Spring Security section for this bean, it will not be able to instatiate one and you get the error.

To make it more difficult, I was specifying this module in gradle and I was expecting things to work. Asuming…

Once I added:

spring:
  security:
    oauth2:
      client:
        registration:
          nameItSomething:
            authorization-grant-type: client_credentials
            client-id: clientNameYouHave
            client-secret: DontShareYourSecretOnTheInternet
        provider:
          nameItSomething:
            token-uri: https://oidcServer/protocol/openid-connect/token

That ClientRegistrationRepository bean started to have a life.

Next bean… Same… I need to add a section for the caching in my application.yaml.