본문으로 바로가기
에러
[2023-08-06 18:18:45:4581][main] ERROR o.s.o.j.LocalContainerEntityManagerFactoryBean o.s.o.j.LocalContainerEntityManagerFactoryBean - Failed to initialize JPA EntityManagerFactory: [PersistenceUnit: default] Unable to build Hibernate SessionFactory; nested exception is java.lang.NullPointerException
[2023-08-06 18:18:47:6160][main] ERROR o.s.boot.SpringApplication o.s.b.SpringApplication - Application run failed
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 javax.persistence.PersistenceException: [PersistenceUnit: default] Unable to build Hibernate SessionFactory; nested exception is java.lang.NullPointerException

 

원인

MSSQL 2012 버전과 jpa 연동에는 이상이 없었으나

MSSQL 2005 버전과 연동 시 에러 발생

처음에 버전 문제인 줄 알았으나 그냥 hibernate 속성 문제였다!

DB를 새로 연동하는 건데 hbm2ddl auto update 로 했으니 에러가 발생하는 것.

 

해결 방법

hbm2ddl.auto : update -> create

  hbm2ddl:
    auto: create

 

 

 

 

참고

https://fors.tistory.com/434

 

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' 에러 해결

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;

fors.tistory.com

 

 

이렇게 쉽게 해결될 줄이야..

MSSQL 2005 버전 문제인줄 알고 시간 허비를 많이 했는데... 

확실히 초반에 잘못 생각하면 그쪽으로 생각이 꽂혀서 시야가 좁아진다..