
✔ 문제
JPA로 테이블을 생성하려고 하는데 다음과 같은 에러가 났다.
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Invocation of init method failed; nested exception is org.hibernate.AnnotationException: No identifier specified for entity: webapp.mysql.model.Board
✔ 해결과정

model 에서 @Id 가 어떤 것으로 import 되었는지 확인하기
위의 org.springframework.data.annotation.Id 로 import 되어있다면
import javax.persistence.Id;
이걸로 변경해준다.
그럼 정상적으로 실행된다.
✔ 원인
javax.persistence.id -> 관계형 데이터베이스
org.springframework.data.annotation.Id -> JPA 가 지원 안되는 spring-data-mongodb, spring-data-solr 등과 같은 다른 스프링 데이터 프로젝트를 다룰 때 일반적으로 사용
✔ 참고
http://snowdeer.github.io/spring-boot/2019/11/28/spring-boot-no-identifier-specified-for-entity/
No identifier specified for entity 문제 해결 · snowdeer's Code Holic
No identifier specified for entity 문제 해결 28 Nov 2019 | SpringBoot No identifier specified for entity 문제 해결 방법 만약 nested exception is org.hibernate.AnnotationException: No identifier specified for entity: com.snowdeer.database.board.
snowdeer.github.io
What's the difference between javax.persistence.Id and org.springframework.data.annotation.Id?
I'd be interested whether there is the difference between javax.persistence.Id and org.springframework.data.annotation.Id. If Spring has created that annotation only for support the JPA annotation,
stackoverflow.com
'개발 > SpringBoot' 카테고리의 다른 글
[오류/해결] Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured. (0) | 2022.08.07 |
---|---|
Spring WebClient / objectMappper (0) | 2022.06.27 |
[SpringBoot] @NotNull @NotEmpty @NotBlank 차이점 (0) | 2022.06.15 |
[SpringBoot] application.yml - h2 database (0) | 2022.06.03 |
@Autowired 필드 주입 , private final 생성자 주입 차이 (0) | 2022.05.31 |