I just stumbled across the same problem and solved it with the @DependsOn annotation. It helps spring to resolve dependencies in an order that makes sense and should be fairly self-explanatory.
Example code:
@DependsOn("liquibase")
public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
@Autowired
private DataSource dataSource;
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
auth.jdbcAuthentication()
.dataSource(dataSource)
// ...
}
@Override
protected void configure(HttpSecurity http) throws Exception {
// ...
}
}
Alternatively there is the depends-on
attribute for XML based configuration.