所以之前我在 springboot 中使用 bcrpytEncoder/passwordEncoder 在 JPA 中使用加密密码注册用户,如下所示:
import org.springframework.context.annotation.Bean;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Component;
@Component
public class PasswordEncoderUtil {
@Bean
public PasswordEncoder passwordEncoder(){
return new BCryptPasswordEncoder();
}
}
然后我使用其他依赖项在我的应用程序中配置 springsecurity :
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-web'
// implementation 'com.okta.spring:okta-spring-boot-starter:3.0.5'
// implementation 'org.springframework.security.oauth.boot:spring-security-oauth2-autoconfigure'
implementation 'org.springframework.boot:spring-boot-starter-security'
implementation 'org.springframework.boot:spring-boot-starter-web-services'
implementation 'org.springframework.boot:spring-boot-starter-actuator'
现在我想从应用程序中删除 springsecurity 并且只想使用 PasswordEncoder ,我应该怎么做?
我不想要这个登录页面: 登录页面
您可以使用单一依赖项
implementation group: 'org.springframework.security', name: 'spring-security-crypto', version: '6.2.4'
这将允许您在应用程序中导入
BCryptPasswordEncoder
类。