반응형
문제
스프링에서 Entity 클래스를 다음과 같이 작성했다.
@Entity
public class User {
@Id
private Long id;
private String firstName;
private int age;
private String email;
}
작성하는 중 분명 @Id 어노테이션을 갖는 필드가 존재함에도 다음과 같은 에러를 뿜으며 애플리케이션 실행이 중지되었다.

해결
잘못된 패키지에서 Id 클래스를 import 하고 있었다. 다음과 같이 변경하여 해결할 수 있었다.
import org.springframework.data.annotation.Id; 변경 -> import javax.persistence.Id;
반응형
'스프링 > 스프링' 카테고리의 다른 글
[Spring] The dependencies of some of the beans in the application context form a cycle 양방향 의존관계 오류 (0) | 2021.08.09 |
---|---|
[Spring] @Scheduled - 스프링에서 주기적인 작업을 진행하는 법 (0) | 2021.05.21 |
[Junit5] 스프링4에서 Junit5의 @ExtendWith(SpringExtension.class) 코드 사용하기 (1) | 2021.04.07 |
[Spring] MVC 프레임워크를 따라 만들어보자. (0) | 2021.02.25 |
[Spring] Model 1, Model 2를 예제로 구현하며 알아보자 (0) | 2021.02.24 |
댓글