작성
·
254
0
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
<version>3.0.4</version>
</dependency>
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.core.userdetails.User;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.provisioning.InMemoryUserDetailsManager;
@Configuration
public class SecurityConfig {
@Bean
UserDetailsService userDetailsService() {
InMemoryUserDetailsManager userDetailsManager = new InMemoryUserDetailsManager();
UserDetails newUser = User.withUsername("user")
.password(passwordEncoder().encode("passw0rd"))
.authorities("read")
.build();
userDetailsManager.createUser(newUser);
return userDetailsManager;
}
@Bean
BCryptPasswordEncoder passwordEncoder() {
return new BCryptPasswordEncoder();
}
}
pom.xml에 있는 spring-boot-starter-security를 주석처리하게 되면 SecurityConfig 클래스에서 오류가 발생합니다. 이 클래스는 그대로 주석처리 하면 되는 건가요?