I just finished an Spring application which is based on the inMemoryAuthentication()
, and now, after verified all are working perfectly, I want use the JDBC Authent
Ok, I solved it. All I needed to do was insert the following annotation in my class SecurityConfig
:
@ComponentScan(value="org.webapp")
And now I can autowire my DataSource
in this class
@Autowired
private DataSource restDataSource;
@Autowired
public void configure(AuthenticationManagerBuilder auth) throws Exception {
auth
.jdbcAuthentication()
.dataSource(restDataSource)
.usersByUsernameQuery(getUserQuery())
.authoritiesByUsernameQuery(getAuthoritiesQuery());
}