aleksandrsl
02/10/2018, 12:00 PMauthenticationProvider that depends on userDetailsServiceProvider
@get: Bean
val userDetailsServiceProvider = JdbcDaoImpl().apply { ... }
@get: Bean
val authenticationProvider = DaoAuthenticationProvider().apply {
setUserDetailsService(userDetailsServiceProvider)
}
And it seems that initialization of authenticationProvider forces userDeatailsServiceProvider bean creation in constructor
public Security(@Autowired @Qualifier("dataSource") @NotNull DataSource appDataSource) {
Intrinsics.checkParameterIsNotNull(appDataSource, "appDataSource");
super();
// Some lines skipped
DaoAuthenticationProvider var7 = new DaoAuthenticationProvider();
var7.setUserDetailsService((UserDetailsService)this.getUserDetailsServiceProvider()); // This seems to be a problem
this.authenticationProvider = var7;
this.securityEvaluationContextExtensionProvider = new SecurityEvaluationContextExtension();
}
And problem is cured by this change
val authenticationProvider
@Bean get() = DaoAuthenticationProvider().apply {
setUserDetailsService(userDetailsServiceProvider)
}
This way initialization of authenticationProvider happens later on demand, when class is constructed and BeanFactory injected.