Consider defining a bean of type 'org.springframework.security.crypto.password.PasswordEncoder '解决方式: @Bean public PasswordEncoder passwordEncoder() { return new BCryptPasswordEncoder(); } String password = passwordEncoder().encode(taco.getPassword());