title: SpringSecurity RememberMeServices is not injected via annotations
body: <p>I am trying to configure SpringSecurity to work with Remember Me authentication.</p>
  
  <p>Here is my Java configuration:</p>
  
  <pre><code>@Configuration
  @EnableWebSecurity
  @EnableGlobalMethodSecurity(securedEnabled = true)
  public class SecurityConfig extends WebSecurityConfigurerAdapter {
  
      @Autowired
      UserDetailsService userDetailsService;
      @Autowired
      DatabasePersistentTokeRepositoryImpl databasePersistentTokeRepositoryImpl;
  
      @Override
      protected void configure(AuthenticationManagerBuilder auth) throws Exception {
          auth.userDetailsService(userDetailsService).passwordEncoder(new BCryptPasswordEncoder());
      }
  
      @Override
      protected void configure(HttpSecurity http) throws Exception {      
          http
          .authenticationProvider(rememberMeAuthenticationProvider())
          .rememberMe().tokenRepository(databasePersistentTokeRepositoryImpl).tokenValiditySeconds((int) TimeUnit.SECONDS.convert(7, TimeUnit.DAYS))
          .and()
              .csrf().disable();
      }
  
      @Bean()
      public AuthenticationProvider rememberMeAuthenticationProvider() {
          return new RememberMeAuthenticationProvider("KEY");
      }
  
      @Bean()
      public TokenBasedRememberMeServices rememberMeServices() {
          TokenBasedRememberMeServices rememberMeServices = new TokenBasedRememberMeServices("KEY", userDetailsService);
          rememberMeServices.setAlwaysRemember(true);
          return rememberMeServices;
      }
  }
  </code></pre>
  
  <p>I see that rememberMeServices is not injected in RememberMeConfigurer. And that results in creating RememberMeAuthenticationFilter which refers to wrong rememberMeServices.</p>
  
  <p>There is a section in Spring Security documentation describing this process using XML.
  <a href="http://docs.spring.io/spring-security/site/docs/3.1.x/reference/springsecurity-single.html#session-mgmt" rel="nofollow">http://docs.spring.io/spring-security/site/docs/3.1.x/reference/springsecurity-single.html#session-mgmt</a></p>
  
  <p>What is wrong with my injection and is it possible do to this without XML after all?</p>