회원가입 암호화하던 도중 예전 프로젝트에선 잘쓰던 BCryptPasswordEncoder가 갑자기 오류가 났다.

bean...bean이 뭐지...
구글링 결과
패키지를 하나 만들어주고

package org.woorin.catudy.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
@Configuration
@EnableWebSecurity
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
@Bean
public BCryptPasswordEncoder pwEncoder() {
return new BCryptPasswordEncoder();
}
@Override
protected void configure(HttpSecurity http) throws Exception {
http.cors().disable()
.csrf().disable()
.formLogin().disable()
.headers().frameOptions().disable();
http.logout().logoutUrl("/memberLogout").logoutSuccessUrl("/");
}
}
Bycrypt 를 사용한 PasswordEncoder bean을 생성해주고 bean을 생성하면
@Autowired를 통해 PasswordEncoder를 선언할때 자동으로 클래스가 바인딩 된다고한다...
나는 말하는 감자여서 아침 9시부터 오후 5시까지 이거만 함^^

심지어 dependency랑 자바스프링 버전이 달라서 이거도 찾는다고 개고생했다.
하지만 결국 내가 이겼다.....이겼다고 ㅠㅠ
'공부중' 카테고리의 다른 글
회원가입할때 유효성 검사 onsubmit 활용하기 (0) | 2022.08.17 |
---|
댓글