본문 바로가기
일지

[SpringBoot] org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource...

by 닉닉눅 2023. 5. 15.
728x90
반응형

SpringBoot 학습을 위해 개인 프로젝트 진행중 MariaDB연동 설정을 마치고 실행하는 과정에서 오류가 발생했습니다.

오류를 해결하기 위해 로그를 확인하며 차분히 해결하기로 했다.

 

첫번째 가능성😈

Caused by: org.hibernate.HibernateException: 
Access to DialectResolutionInfo cannot be null when 'hibernate.dialect' not set

JPA의 hibernate.dialect가 설정되지 않아서 오류가 발생한다고 합니다.

저는 MariaDB를 사용하고 있으므로 application.properties에 다음 내용을 추가했습니다.

 

spring.jpa.database=mysql

 

하지만, 오류의 내용이 다른 것으로 바뀌었을 뿐 해결되지 않았습니다.😥

 

두번째 가능성😈

application.properties의 DB 접속 정보에 오타가 발생했을 경우를 생각했습니다.

spring.mvc.pathmatch.matching-strategy=ant_path_matcher

spring.datasource.driver-class-name=org.mariadb.jdbc.Driver
spring.datasource.url=jdbc:mariadb://localhost:3308/test_shop
spring.datasource.username=root
spring.datasource.password=1122

spring.jpa.database=mysql
spring.jpa.hibernate.ddl-auto=create
spring.jpa.show-sql=true

*저는 PC에 MySQL도 설치되어 있어 MariaDB는 3308번 포트를 사용합니다.

이번에도 잘못된 점을 찾을 수 없었습니다.😪

 

DB 연동 과정에서 발생하는 오류를 생각하며 확인하던 중 저번에 작성했던 SpringBoot버전으로 생긴 문제가 떠올라 SpringBoot의 버전을 2.7.5로 낮췄습니다.

드디어 너무 보고 싶었던 서버 정상 실행 메시지입니다!!!😂😂

 

해결방법 : SpringBoot 2.7.8 -> SpringBoot 2.7.5 버전 다운

 

알아보니 스프링부트 버전과 자바버전등 환경의 문제로 2.7.7 이상 버전에서는 오류가 발생하는 현상이 있다고합니다.

 

프로젝트 생성 시 SpringBoot의 Reference Doc.을 참고하여 권장하는 버전을 사용해야겠습니다.

 

다음에 시간이 되면  Reference Doc.을 통해 버전을 확인하는 방법에 대한 글을 작성하겠습니다.

 

https://spring.io/projects/spring-boot#learn

 

Spring Boot

 

spring.io

 

728x90
반응형

댓글