Could not create JPA EntityManager nested exception is org hibernate service spi serviceexception

이전 글 이후에 작업을 할 수가 없었다.

왜냐하면 약 3일간 나에게 Time zone 에러라는 고난이 찾아왔기 때문이다.

Could not create JPA EntityManager nested exception is org hibernate service spi serviceexception
진짜 울 뻔 했다.

이 에러로 나는 windows를 날리고 리눅스를 깔아야 할지 고민하였고,

우분투를 노트북에 다운로드하여 설치하였고,

잘 돌아가던 MySQL 8.0 버전을 지우고 5.7.27 버전으로 다시 설치하였으며

그 외에도 진짜 온갖 방법은 다 썼다.

그렇게 미친 듯이 고생해서 에러를 어떻게 해결했는지 지금부터 한번 정리해보겠다.

참고로 너무 많은 짓을 해서 기억도 잘 안 나니 양해 바란다.

Could not create JPA EntityManager nested exception is org hibernate service spi serviceexception
이게 시작이었지...

일단 시작은 html 파일을 작성한 내가 제대로 실행이 되는지 궁금해서 run을 누른 것으로부터 발생하였다.

사수께서 알려주신 대로 맨 마지막 에러를 확인하였고...

Could not create JPA EntityManager nested exception is org hibernate service spi serviceexception

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

구글에 위의 에러를 검색을 해서 application.yml 파일에서 설정이 되어있는지 확인을 했지만, 잘 되어있었다.

그래서 차선책으로 맨 위의 에러를 확인해보았는데,

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.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]

나오는 것은 변함없이 설정에 관한 것뿐이었다.

그나마 그중에 해결책으로 제시된 XML 파일을 추가해 보았지만........

Could not create JPA EntityManager nested exception is org hibernate service spi serviceexception

여전히 시공에서 벗어나지 못하는 것처럼, 에러에 빠져 삽질을 하던 중 그가 오셨다.

Time zone 에러

java.sql.SQLException: The server time zone value '´ëÇѹα¹ Ç¥ÁؽÃ' is unrecognized or represents more than one time zone. You must configure either the server or JDBC driver (via the serverTimezone configuration property) to use a more specifc time zone value if you want to utilize time zone support.

처음에는 이놈은 대체 뭐길래 글자까지 깨져서 나오나 싶어 다시 구글에 검색해보았다.

MySQL의 오류인데 time zone이 제대로 설정되지 않아 생긴 에러라는 것을 알게 되었고,

드디어 이 길고 긴 에러의 늪에서 벗어난다 생각하니 행복했는데....

Could not create JPA EntityManager nested exception is org hibernate service spi serviceexception
돌아가라, 이 악마야 ㅠㅠㅠ

전혀 아니었다.

검색을 해본 뒤 MySQL Command Line Client에서 설정도 해보고

Could not create JPA EntityManager nested exception is org hibernate service spi serviceexception

MySQL에 들어가서 system_time_zone을 눌러서 뜬 에러 처리하겠다고 난리 좀 치다가

Could not create JPA EntityManager nested exception is org hibernate service spi serviceexception

그 후 약 하루라는 시간이 흐른 뒤 반 포기하는 심정으로 사수 코드와 비교해보았더니

Could not create JPA EntityManager nested exception is org hibernate service spi serviceexception

build 해서 가져온 버전의 문제인가 싶어 MySQL 8.0을 지우고 5.7.27 버전으로 다시 깔았고,

그럼에도 여전히 에러는 나에게 고통을 주었고, 결국 주변 개발자 분들께 도움을 요청하였다.

학원분들께 여쭤봤더니 우분투를 사용해보면 어떻겠냐는 이야기에 우분투를 설치했고..

Could not create JPA EntityManager nested exception is org hibernate service spi serviceexception
물론 사용은 안했다.

사용법을 몰라 허우적거리다 결국 사수께 카톡을 하여 에러 코드 전체를 보냈으며

그 후 30분 뒤... 사수가 알려주신 대로

application.yml 파일에 들어가서

datasource:
    url: jdbc:mysql://localhost:3306/resume 를

datasource:
    url: jdbc:mysql://localhost:3306/resume?serverTimezone=UT 로 변경하였더니

Time zone 에러를 해결할 수 있었다.

Could not create JPA EntityManager nested exception is org hibernate service spi serviceexception

그래도 뭐 다른 에러가 나왔으니.. 일단 좀 쉬고 다시 작업해야겠다..

- 회고 -

MySQL이 많이 사용되는 DB인 만큼 분명 다뤄보는 게 좋다는 마음으로 시작했지만

Spring boot에서 H2 설정을 제공해주는 것이 얼마나 편하고 좋은 것인지 정말 많이 느꼈다.

사용 방법이 다르니 물론 힘들긴 하지만 한 가지의 DB만 사용할 줄 알면 된다 생각했는데

지금처럼 DB를 공부하는데 자주 사용되는 MySQL을 다루며 여러모로 나에게 많이 남을 것 같고,

이번 기회로 익숙함에 편한 것만 사용하는 것을 추구하기보단 새로운 기술을 사용해야 하는 기회가 생겼을 때

나 자신의 발전을 위해서라도 좀 더 편하게 받아들일 수 있을 것 같다.