TIL
항해99_WIL220703 (실전프로젝트 1주)
Hyeongjun_Ham
2022. 7. 4. 10:19
1주차 나온 이슈들 정리
- @Service를 넣었는데도 Bean을 못찾음
- 패키지 위치 잘못만듬
- @ConponentScan의 찾는 범위가 같은 패키지 안에서만 찾는 것으로 보인다.
- SpringBoot Could not find acceptable representation(Error: Request failed with status code 406)
- 리턴 값에 @Getter를 추가해주니 해결
- UserDetailImpl에 유저 정보를 못가져옴
- @AuthenticationPrincipal 누락함
- 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의 개념을 더 공부해야할 것 같다.
- No EntityManager with actual transaction available for current thread - cannot reliably process 'remove' call
- deleteAllby 사용시에 이런 에러가 발생했다.
- 해결법 : 삭제를 수행할 메소드 위에 @Transactional 어노테이션을 붙여준다.
@Transactional
public void deleteAlarms(UserDetailsImpl userDetails) {
Long id = userDetails.getMember().getId();
alarmRepository.deleteAllByMemberId(id);
}
- has been compiled by a more recent version of the Java Runtime
- 배포시에 ec2컴퓨터에서 이런에러가 났다.
- 이전에 자바 8버전으로 배포를 했고, 이번에 11버전으로 배포를 하려해서 에러가 났다.
- ec2컴퓨터에 jdk 11 설치하여 해결함!