0

I am trying out this Baeldung tutorial (https://www.baeldung.com/spring-webclient-oauth2) and was wondering how to inject the parameter

ReactiveClientRegistrationRepository clientRegistrations

that holds the configured credentials into a functional bean:

context.registerBean(
            "beanName",
            BeanClass.class,
            () -> {
// ?
}

Is that possible and if so, how does it work?

Many thanks

Christian
  • 11
  • 2
  • A lambda can access any effectively final variable and basically "bakes" the value/reference into the lambda. If `clientRegistrations` isn't considered effectively final by the compiler, create a local final variable and use this, e.g. `final ReactiveClientRegistrationRepository finalClientRegistrations = clientRegistrations;` and then `() -> { finalClientRegistrations.whatever(); }` – Thomas Nov 09 '21 at 08:16
  • i think, you just want this: https://www.baeldung.com/spring-value-annotation (?) or this https://stackoverflow.com/q/50928752/592355 e.g. – xerx593 Nov 09 '21 at 08:16

0 Answers0