Also you can define in your @Configuration beans, but is recommend to define password encoder in your @@EnableWebSecurity beans, it is automatically add @Configuration annotation for you and you can config more security related things.
@EnableWebSecurity
public class YourWebConfiguration extends WebSecurityConfigurerAdapter {
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
auth.userDetailsService(userDetailsService).passwordEncoder(new BCryptPasswordEncoder());
}
}