본문 바로가기

공부/Spring

스프링 부트 3 백엔드 개발자 되기_29

 

08장 218pg 테스트 중

 

<오류> 
Caused by: org.hibernate.AnnotationException: Entity 'today.simba.springbootdeveloper.domain.User' has no identifier (every '@Entity' class must declare or inherit at least one '@Id' or '@EmbeddedId' property)

=> User.java 확인하기 
<코드확인1>

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id", updatable = false)
    private Long id;



위 코드 보면
@Id 어노테이션 쓰고 있는데 
import org.springframework.data.annotation.Id;
import jakarta.persistence.*;
둘다 임포트 하고 있었음

import org.springframework.data.annotation.Id; 를 지우고 

@Id를 지우고 다시 쓰면서 뭐 임포트할지 고를 때  import jakarta.persistence.*    선택

=>
해결

 

참고글

https://2-juhyun-2.tistory.com/769