java - JPA - Spring Boot - 密码编码

标签 java spring-boot

我是 JPA 和 Spring Boot 的新手。

http://www.baeldung.com/spring-security-registration-password-encoding-bcrypt

我正在寻找对密码进行编码 - 我将把这个 bean 放在哪里 - 我只是在我的 application.properties 中还是在 pom.xml 中定义它

最佳答案

您也可以在@Configuration bean中定义,但建议在@@EnableWebSecurity bean中定义密码编码器,它会自动为您添加@Configuration注释,您可以配置更多与安全相关的内容。

@EnableWebSecurity
public class YourWebConfiguration extends WebSecurityConfigurerAdapter {

    @Autowired
    public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
        auth.userDetailsService(userDetailsService).passwordEncoder(new BCryptPasswordEncoder());
    }
}

关于java - JPA - Spring Boot - 密码编码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46065743/

相关文章:

java - 从 HDFS 下载大文件

spring - Azure 服务总线 - Spring Boot 禁用自动启动 (com.microsoft.azure : azure-servicebus-spring-boot-starter)

spring - server.error.path 属性究竟是什么?

java - 有哪些方法可以测试依赖于静态方法的方法?

java - 在两个 Web 应用程序之间共享实例时 Maven Jetty 插件 OutOfMemoryError

java - google-collection 的 LazyMap 在哪里?

javascript - Spring Boot 缩小 javascript

spring-boot - 我如何在 Spring Boot-1.4.1-RELEASE 中制作 init-sql

java - 使用 Spring Data Embedded Mongo 在 Mongo 数据库中导入 JSON 文件

java - 是否可以在 Java 9 中禁用模块?