title: My log in account is not valid in spring boot
body: <p>I want to log in with the accounts provided in userdetails method in spring boot, but it is not working. Here is my WebSecurityConfiguration class. It is giving me bad credentials.Any idea?
  I am new to spring boot.</p>
  <pre><code>
  @Configuration
  @EnableWebSecurity
  public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
  
      private PasswordEncoder passwordEncoder;
  
      @Autowired
      public SecurityConfiguration(PasswordEncoder passwordEncoder) {
          this.passwordEncoder = passwordEncoder;
      }
  
  
      @Override
      protected void configure(HttpSecurity http) throws Exception {
          http
                  .authorizeRequests()
                  .antMatchers(&quot;/api/admin&quot;).hasRole(&quot;admin&quot;)
                  .antMatchers(&quot;/api/user&quot;).hasRole(&quot;user&quot;)
                  .antMatchers(&quot;/api/student&quot;).hasRole(&quot;STUDENT&quot;)
                  .antMatchers(&quot;/api/computer&quot;).hasRole(&quot;COMPUTER&quot;)
                  .antMatchers(&quot;/api/root&quot;).permitAll()
                  .anyRequest().authenticated()
                  .and().httpBasic()
                  .and().formLogin();
      }
  
      @Override
      protected UserDetailsService userDetailsService() {
          UserDetails user = User.builder()
                  .username(&quot;student&quot;)   //ROLE_STUDENT
                  .password(passwordEncoder.encode(&quot;student&quot;))
                  .roles(&quot;STUDENT&quot;)
                  .build();
  
          UserDetails user2 = User.builder()
                  .username(&quot;computer&quot;)
                  .password(passwordEncoder.encode(&quot;computer&quot;))
                  .roles(&quot;COMPUTER&quot;)
                  .build();
  
          return new InMemoryUserDetailsManager(user, user2);
      }
  }
  </code></pre>