title: Spring security custom login form not invoked
body: <p>I am trying to configure spring MVC web application to use custom login form for authentication using annotations. My problem is that custom login form is never opened, but instead of it I always get standard spring security login form.</p>
  
  <p>I have defined the following <code>SecurityConfiguration</code> class:</p>
  
  <pre><code>package com.test.spring.config;
  
  import org.springframework.beans.factory.annotation.Autowired;
  import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
  import org.springframework.security.config.annotation.web.builders.HttpSecurity;
  import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
  
  @EnableWebSecurity
  public class SecurityConfiguration {
  
      @Autowired
      public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
          auth
              .inMemoryAuthentication()
                  .withUser("user").password("password").roles("USER");
      }
  
      protected void configure(HttpSecurity http) throws Exception {
          http
              .authorizeRequests()
                  .antMatchers("/login").permitAll()  
                  .antMatchers("/resources/**").permitAll()
                  .antMatchers("/admin/**").hasRole("ADMIN")
                  .and()
              .formLogin()
                  .loginPage("/login")
                  .defaultSuccessUrl("/home")
                  .usernameParameter("user_login")
                  .passwordParameter("user_password")
                  .and()
              .logout()
                  .logoutUrl("/logout")
                  .logoutSuccessUrl("/login")
                  .permitAll()
                  .and()
              .csrf()
                  .and()
              .sessionManagement()
                  .invalidSessionUrl("/login?time=1")
                  .maximumSessions(10);
      }
  
  }
  </code></pre>
  
  <p>And <code>SecurityWebApplicationInitializer</code> class:</p>
  
  <pre><code>package com.test.spring.config;
  
  import org.springframework.security.web.context.AbstractSecurityWebApplicationInitializer;
  
  public class SecurityWebApplicationInitializer extends AbstractSecurityWebApplicationInitializer {
  
  }
  </code></pre>
  
  <p>Also I created custom login form as <code>login.html</code> so I assumed that the configuration would load my <code>login.html</code> file instead standard spring security login form.</p>
  
  <p>Whatever I do, I always get the standard login form:</p>
  
  <p><a href="https://i.stack.imgur.com/ELuHC.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ELuHC.png" alt="enter image description here"></a></p>
  
  <p>I have also configured my controller:</p>
  
  <pre><code>    @RequestMapping(value = "/login", method = RequestMethod.GET)
      public String login() {
          return "login";
      }
  </code></pre>
  
  <p>It seems that my security configuration wasn't loaded at all.</p>
  
  <p>Where is the problem?</p>