title: method in class AuthenticationManagerBuildier cannot be applied to given type
body: <p>I am trying to encrypt a password into the database with spring security however i get the error. My spring security class is returning an error when i try to encode the password. I am not sure where i am going wrong.</p>
  
  <p>This image shows the error being thrown by the security class:</p>
  
  <p><a href="https://i.stack.imgur.com/MJ2qr.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/MJ2qr.png" alt="enter image description here"></a></p>
  
  <p><strong>SecurityConfig.java</strong></p>
  
  <pre><code>@Configuration
  @EnableWebSecurity
  public class SecurityConfig extends WebSecurityConfigurerAdapter {
  
  @Autowired  
  private UserService userService;
  
  protected void configure(AuthenticationManagerBuilder auth) throws Exception {
      auth.userDetailsService(userService).passwordEncoder(passwordEncoder());
    }
  
  @Bean
  public PasswordEncoder passwordEncoder() {
      return new BCryptPasswordEncoder();
     }
  }
  </code></pre>
  
  <p><strong>ApplicationAuthenticationSuccessHandler.java</strong></p>
  
  <pre><code>public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response, Authentication
          authentication) throws IOException, ServletException {
      User user = (User) authentication.getPrincipal();
      request.getSession().setAttribute("authenticated_user", user);
      super.onAuthenticationSuccess(request, response, authentication);
  }
  </code></pre>
  
  <p><strong>UserService.java</strong></p>
  
  <pre><code>@Service
  @Transactional
  public class UserService {
  @Autowired
  private UserRepository userRepository;
  
  @Autowired
  private PasswordEncoder passwordEncoder;
  
  public Response createUser(User user) {
        if( user == null || user.getId() == null){
            throw new ResourceNotFoundException("Empty", "Missing Data Exception");
        } else {
            user.setPassword(passwordEncoder.encode(user.getPassword()));
            userRepository.save(user);
            return new Response(user.getId(), "Customer Created Successfully");
        }
  
   }
  </code></pre>
  
  <p><strong>User.java</strong></p>
  
  <pre><code>@Entity
  public class User implements Serializable, UserDetails {
  @NotBlank
  private String surname;
  
  @NotBlank
  @Size(min = 5, max = 20, message = "Please enter between {min} and {max} characters.")
  private String phoneNumber;
  
  @NotBlank
  @Size(min = 5, max = 100, message = "Please enter between {min} and {max} characters.")
  private String password;
  }
  </code></pre>
  
  <p><strong>RegisterController.java</strong></p>
  
  <pre><code>@RestController
  public class RegisterController {
  
  @Autowired
  private UserService userService;
  
  @RequestMapping(method = RequestMethod.POST, value = "/users")
  public Response createUser(@Valid @RequestBody User user){
      return userService.createUser(user);
  
     }
   }  
  </code></pre>