'how can i make BCryptPasswordEncoder() work in spring because in my application can't find that classes
how can i make BCryptPasswordEncoder() work in spring because in my application can't find that class about that and the message is not matching for dependencies i can't find another solve with mongodb .
Solution 1:[1]
If you wan't to use BCryptPasswordEncoder()
you must add to your dependencies (POM if your are using Maven) this:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
Then, you can use it in your Class with this import.
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
Solution 2:[2]
As Diego said you need you need this.
Here is a quick snippet to show you how to use it.
public static void main(String[] args) {
String password = "admin@admin";
BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder();
System.out.println("Encoded password is " + passwordEncoder.encode(password));
}
Solution 3:[3]
Add this dependency
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-crypto</artifactId>
<version>3.1.0.RELEASE</version>
</dependency>
Solution 4:[4]
Add this dependency:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Diego Fernández Peces-Barba |
Solution 2 | Ajay Kumar |
Solution 3 | Tinashe |
Solution 4 | awpk |