Now, we will provide the created UserCache bean to AuthenticationProvider:
@Bean
public AuthenticationProvider authenticationProviderBean() {
DaoAuthenticationProvider authenticationProvider = new
DaoAuthenticationProvider();
authenticationProvider.setPasswordEncoder(passwordEncoder);
authenticationProvider.setUserCache(userCache);
authenticationProvider.
setUserDetailsService(userDetailsService());
return authenticationProvider;
}