πŸ“ 기둝/πŸ–οΈ Error Note

Java/Spring | Unsatisfied dependency expressed through field 'pwEncoder';

  • -

Error

Spring Security pwEncoder λ₯Ό μ‚¬μš©ν•˜κΈ° μœ„ν•΄ μ μš©ν•˜λ˜ 쀑 λ°œμƒ.

Error creating bean with name '...controller': Unsatisfied dependency expressed through field 'pwEncoder';
λ²ˆμ—­: 'pwEncoder' ν•„λ“œλ₯Ό 톡해 ν‘œν˜„λœ 뢈만쑱슀러운 μ˜μ‘΄μ„±;

'빈 μƒμ„±μ‹œμ— ν•„μš”ν•œ 것이 λΉ μ‘Œκ±°λ‚˜, 잘λͺ»λ˜μ—ˆμœΌλ‹ˆ 고쳐라' λŒ€μΆ© 이런 λ‚΄μš©μΈ λ“― ν•˜λ‹€.

 

Solution Content

빈이 λ“±λ‘λ˜λŠ” 뢀뢄듀을 μ‚΄νŽ΄λ³΄κ³  λˆ„λ½λœ μ–΄λ…Έν…Œμ΄μ…˜μ΄ μžˆλŠ”μ§€ 확인할 것.
spring μ„€μ •μ—μ„œ ν•„μš”ν•œ 빈 등둝 μ½”λ“œκ°€ λˆ„λ½λ˜μ—ˆλŠ”μ§€ 확인할 것.

ν•„μžλŠ” context 에 빈 등둝 μ½”λ“œκ°€ λˆ„λ½λ˜μ–΄ λ°œμƒν•œ μ—λŸ¬.

 

Before

// μ½”λ“œ

 

After

// spring src κ²½λ‘œμ— μžˆλŠ” .xml νŒŒμΌμ— μ½”λ“œ μΆ”κ°€
<!-- 단방ν–₯ μ•”ν˜Έν™” 빈 등둝 -->
<bean id="passwordEncoder" class="org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder"/>
Contents

ν¬μŠ€νŒ… μ£Όμ†Œλ₯Ό λ³΅μ‚¬ν–ˆμŠ΅λ‹ˆλ‹€

이 글이 도움이 λ˜μ—ˆλ‹€λ©΄ 곡감 λΆ€νƒλ“œλ¦½λ‹ˆλ‹€.