2023.07.12 TIL
2023. 7. 12. 20:21ㆍTIL(Today I Learned)
(1) Spring Security 객체를 Servlet-Context.xml에 추가하면 에러가 나는데 Root-Context.xml에 추가하면 에러가 안나는 이유
- 스프링을 실행하면 컨테이너에 bean들을 만든다. dependency에 뭔가 만족되지 않는 이유는 servlet바구니 안쪽에 bcryptPasswordEnconder를 만들어주었는데도 MemberService 측에서 찾지 못하게 됨.
- root바구니 안쪽에도 MemberService 객체가 만들어져 있고 인코더를 필요로 하고 잇는데 servlet-context에 접근할 수 없어서 에러가 난 것이다.
- root-context에 encoder를 추가하면 root와 servlet 모두다 접근이 가능하다.
그래서, root-context.xml에 이걸 추가하자.
<context:component-scan base-package="com.kh.app" use-default-filters="false">
이렇게 하면 root 바구니에 Controller, Service, Dao가 들어오지 않는다.
'TIL(Today I Learned)' 카테고리의 다른 글
2023.07.14 TIL (0) | 2023.07.14 |
---|---|
2023.07.13 TIL (0) | 2023.07.13 |
2023.07.07 TIL (0) | 2023.07.07 |
2023.07.03 TIL (0) | 2023.07.03 |
2023.06.23 TIL (0) | 2023.06.23 |