Description
Attempting to setup a Spring Boot application that is not a Web Application, unable to rely on auto configuration of OAuth2Client due to OAuth2ClientAutoConfiguration
having @ConditionalOnWebApplication(type = ConditionalOnWebApplication.Type.SERVLET)
.
The batch job we are attempting to setup has a client to a Rest API that requires OAuth2 authentication. When attempting to Autowire ClientRegistrationRepository
and OAuth2AuthorizedClientService
into a Bean method in order so setup the RestClient
, received error that Parameter 1 of method oauth2RestClient in com.sample.batch.configuration.RestClientConfiguration required a bean of type 'org.springframework.security.oauth2.client.registration.ClientRegistrationRepository' that could not be found
.
We were able to get around this by providing our own ClientRegistrationRepository
and OAuth2AuthorizedClientService
beans, but I believe that these auto configured beans should not require the Spring Boot app to be running in a servlet environment.