TIL
항해99_TIL220629 (실전프로젝트 7일차)
Hyeongjun_Ham
2022. 6. 29. 23:58
오늘 나온 에러
- SpringBoot Could not find acceptable representation(Error: Request failed with status code 406)
리턴 값에 @Getter를 추가해주니 해결되었다.
- UserDetailImpl에 @AuthenticationPrincipal 안 적어서 계속 유저 정보를 못가져옴
@AuthenticationPrincipal 어노테이션
스프링 시큐리티를 활용하여 인증,인가를 처리할 때 @AuthenticationPrincipal를 쓰면 쉽게 UserDetails를 구현하여 만든 Principal 인스턴스를 얻을 수 있었다. 쉽게 사용했지만 어떻게 동작하는지 궁금해져
cantcoding.tistory.com
- could not initialize proxy - no session 에러
문제 :
Member member = userDetails.getMember();
해결 :
Long id = userDetails.getMember().getId();
Member member = memberRepository.findById(id).orElseThrow(
() -> new IllegalArgumentException("로그인한 상태가 없습니다.")
);
영속성 컨텍스트의 프록시,Lazy Loading의 개념을 더 공부해야할 것 같다.
출처 : https://cantcoding.tistory.com/78
JPA/ could not initialize proxy - no Session
1.문제점 JPA를 통한 개발을 하다보면 한번쯤 만날 수 밖에없는 에러이다. JPA를 사용하여 DB에 저장된 리소스를 불러와서 반환하는 경우, 혹은 사용할 때 발생했던 에러이다. 2.접근 JPA에 대한 이
cantcoding.tistory.com