반응형
- 스프링이 뽑은 object를 Bean이라고 합니다.
- Bean으로 등록해두면 사용 할 때마다 객체를 생성하는 것이 아니라, DI로 가져다 쓸 수 있다.
- 그러면 한 번 뽑아놓은 object를 계속 재사용하니까 매번 new 안해도 되어서 효율적
BcryptPasswordEncoder Bean 등록
- SecurityConfig
@Bean
public PasswordEncoder passwordEncoder() {
return new BCryptPasswordEncoder();
}
- Service Layer
private final PasswordEncoder passwordEncoder;
의존성 주입으로 받아서 사용한다.
'study > Spring' 카테고리의 다른 글
Content-Type 'application/x-www-form-urlencoded;charset=UTF-8' is not supported. (0) | 2024.09.20 |
---|---|
Spring Security 로그인 (0) | 2024.08.16 |
메모리 구조 (0) | 2024.08.14 |
[Spring Boot] 환경 설정 및 설치 (0) | 2023.01.25 |