티스토리 뷰
1일 1삽질
Spring의 순환참조 (The dependencies of some of the beans in the application context form a cycle)
sayho 2022. 9. 3. 15:08SecurityConfig.kt
class SecurityConfig(
private val jwtAuthenticationProvider: JwtAuthenticationProvider,
SecurityConfig 에서는 JWTConfig 에 Provider를 인자로 넘겨주기 때문에 JwtAuthenticationProvider 를 주입받는다.
JwtAuthenticationProvider
@Component
class JwtAuthenticationProvider(
@Value("\${jwt.secret}")
val secret: String,
@Value("\${jwt.token-validity-in-seconds}")
val tokenValidityInSeconds: Long,
private val jwtUserDetailsService: JwtUserDetailsService
JwtAuthenticationProvider 에서는 JwtUserDetailsService 를 통해 사용자의 정보를 가져와서 인증과정을 진행해야하기 때문에 JwtUserDetailsService 를 주입받는다.
JwtUserDetailsService
@Component
class JwtUserDetailsService(
private val userService: UserService
JwtUserDetailsService 는 username 을 통해 userDetails 를 가져오기 위해 UserService 를 주입받았다
JwtUserDetailsService
@Service
class UserService(
private val userEntityRepository: UserEntityRepository,
private val passwordEncoder: PasswordEncoder
UserService는 Security Config 에 빈으로 등록된 passwordEncoder 를 주입받는다.
SecurityConfig -> JwtAuthenticationProvider -> JwtUserDetailsService -> JwtUserDetailsService -> SecurityConfig
로 서로 주입받아서 순환이 생겨버린것..
해결방법은 순환이 생기지 않도록 연관관계를 끊어주도록 설계하면 됨
'1일 1삽질' 카테고리의 다른 글
ORA-39710: only connect AS SYSDBA is allowed when OPEN in UPGRADE mode 해결방안 (1) | 2023.09.26 |
---|---|
[Spring] Apache POI Column was never explicitly tracked and isAllColumnsTracked() is false 에러 (0) | 2023.07.11 |
[Mysql] this is incompatible with sql_mode=only_full_group_by 해결 방법 (0) | 2022.08.13 |
Kotlin 에서 RequestDto 에 @Valid 적용하기 (0) | 2022.08.07 |
JPAN+1 예제 (0) | 2022.07.24 |
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- 람다식
- 인덱스
- 운영체제
- JPA
- 기술면접
- SpringSecurity
- ORA-27125
- CodeDeploy
- TCP
- ci/cd
- 프로그래머스
- Travis CI
- 네이버클라우드
- graphql
- level0
- OS
- 트랜잭션격리성
- SpringGraphQL
- AWS
- Til
- ddl-auto
- 파일업로드설정
- EC2
- nginx
- Java
- spring
- N+1
- 트랜잭션
- db
- Oracle
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | |
7 | 8 | 9 | 10 | 11 | 12 | 13 |
14 | 15 | 16 | 17 | 18 | 19 | 20 |
21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 | 29 | 30 | 31 |
글 보관함