본문 바로가기
개발/SpringBoot

[해결] 스프링 BeanCreationException:, org.hibernate.AnnotationException 에러

by yo.na 2022. 3. 11.

✔ 문제

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

https://stackoverflow.com/questions/39643960/whats-the-difference-between-javax-persistence-id-and-org-springframework-data

 

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