개발

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 fail..

시간의 효율화 2022. 3. 7. 14:13

컴파일 하는 데 다음과 같은 에러가 떴다. 

 

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 
org.hibernate.exception.SQLGrammarException: Unable to build DatabaseInformation

 검색 해보니 Dialect를 잘못 설정해줘서 그런 것이다. 

 

H2를 사용하다가 MySQL로 고쳤는데, dialect 변경을 못 해줬다. 

 

이거에서 

spring.jpa.database-platform=org.hibernate.dialect.H2Dialect

 

이걸로 고치니 작동 되었다. 

spring.jpa.database-platform=org.hibernate.dialect.MySQL8Dialect

 

출처:

https://stackoverflow.com/questions/26881739/unable-to-get-spring-boot-to-automatically-create-database-schema

 

Unable to get spring boot to automatically create database schema

I'm unable to get spring boot to automatically load my database schema when I start it up. Here is my application.properties: spring.datasource.url=jdbc:mysql://localhost:3306/test spring.datasou...

stackoverflow.com