title: Error: Required a bean of type 'org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder' that could not be found
body: <p>I want to use Spring Boot Security in my project by creating a simple login screen but i get these error while running y application</p>
  <p><strong>Description:
  Parameter 1 of constructor in com.panchmeru_studio.controller.UserController required a bean of type 'org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder' that could not be found.</strong></p>
  <p><strong>Action:Consider defining a bean of type org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder' in your configuration.</strong>
  Here is my code.</p>
  <blockquote>
  <p>UserController</p>
  </blockquote>
  <pre><code>package com.panchmeru_studio.controller;
  
  import com.panchmeru_studio.entities.ApplicationUser;
  import com.panchmeru_studio.repository.ApplicationUserRepository;
  import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
  import org.springframework.web.bind.annotation.*;
  
  @RestController
  @RequestMapping(&quot;/users&quot;)
  public class UserController {
  
      private ApplicationUserRepository applicationUserRepository;
      private BCryptPasswordEncoder bCryptPasswordEncoder;
  
      public UserController(ApplicationUserRepository applicationUserRepository,
                            BCryptPasswordEncoder bCryptPasswordEncoder) {
          this.applicationUserRepository = applicationUserRepository;
          this.bCryptPasswordEncoder = bCryptPasswordEncoder;
      }
  
      @PostMapping(&quot;/record&quot;)
      public void signUp(@RequestBody ApplicationUser applicationUser) {
          applicationUser.setPassword(bCryptPasswordEncoder.encode(applicationUser.getPassword()));
          applicationUserRepository.save(applicationUser);
      }
  }
  </code></pre>
  <blockquote>
  <p>SecurityConfiguration.java</p>
  </blockquote>
  <pre><code>package com.panchmeru_studio.security;
  
  import com.panchmeru_studio.filter.AuthenticationFilter;
  import com.panchmeru_studio.filter.AuthorizationFilter;
  
  import com.panchmeru_studio.service.ApplicationUserDetailsService;
  import org.springframework.context.annotation.Bean;
  import org.springframework.context.annotation.Configuration;
  import org.springframework.http.HttpMethod;
  import org.springframework.security.authentication.AuthenticationManager;
  import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
  import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
  import org.springframework.security.config.annotation.web.builders.HttpSecurity;
  import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
  import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
  import org.springframework.security.config.http.SessionCreationPolicy;
  import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
  import org.springframework.security.crypto.password.PasswordEncoder;
  import org.springframework.web.cors.CorsConfiguration;
  import org.springframework.web.cors.CorsConfigurationSource;
  import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
  
  import static com.panchmeru_studio.constants.SecurityConstants.SIGN_UP_URL;
  
  @Configuration
  @EnableWebSecurity
  @EnableGlobalMethodSecurity(prePostEnabled = true)
  public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
  
      private ApplicationUserDetailsService userDetailsService;
      private BCryptPasswordEncoder bCryptPasswordEncoder;
  
      public SecurityConfiguration(ApplicationUserDetailsService userDetailsService, BCryptPasswordEncoder bCryptPasswordEncoder) {
          this.userDetailsService = userDetailsService;
          this.bCryptPasswordEncoder = bCryptPasswordEncoder;
      }
  
      @Override
      protected void configure(HttpSecurity http) throws Exception {
          http.cors().and().csrf().disable().authorizeRequests()
                  .antMatchers(HttpMethod.POST, SIGN_UP_URL).permitAll()
                  .anyRequest().authenticated()
                  .and()
                  .addFilter(new AuthenticationFilter(authenticationManager()))
                  .addFilter(new AuthorizationFilter(authenticationManager()))
                  .sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS);
      }
      @Bean
      CorsConfigurationSource corsConfigurationSource() {
          final UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
          source.registerCorsConfiguration(&quot;/**&quot;, new CorsConfiguration().applyPermitDefaultValues());
          return source;
      }
  
      @Override
      public void configure(AuthenticationManagerBuilder auth) throws Exception {
          auth.userDetailsService(userDetailsService).passwordEncoder(bCryptPasswordEncoder);
      }
      
  
  
      @Override
      @Bean
      public AuthenticationManager authenticationManagerBean() throws Exception {
          return super.authenticationManagerBean();
      }
  
  
  }
  </code></pre>