Spring Security(Third Edition)
上QQ阅读APP看书,第一时间看更新

Configuring a JDBC UserDetailsManager implementation

We'll modify the SecurityConfig.java file to declare that we're using a JDBC UserDetailsManager implementation, instead of the Spring Security in-memory UserDetailsService implementation that we configured in Chapter 2, Getting Started with Spring Security. This is done with a simple change to the UserDetailsManager declaration, as follows:

    //src/main/java/com/packtpub/springsecurity/configuration/SecurityConfig.java


@Bean
@Override
public UserDetailsManager userDetailsService() {
JdbcUserDetailsManager manager = new JdbcUserDetailsManager();
manager.setDataSource(dataSource);
return manager;
}

We replace the previous configure(AuthenticationManagerBuilder) method, along with all of the child elements, with the userDetailsService() method, as shown in the preceding code snippet.