38강 Cannot load driver class: org.h2.driver
2220
작성한 질문수 2
안녕하십니까. 다름이 아니라 profile을 local로 실행 시 오류가 나서 질문을 드립니다.
인텔리제이 Community 버전이라서
VM option 추가 후, -Dspring.profiles.active=local를 입력헀습니다.
실행을 할때 local 프로필이 활성화가 되었다고 하지만
오류가 발생합니다. VM option이 잘못된건가 싶어서
-Dspring.profiles.active=dev로 설정 시 MySQL이 정상적으로 작동합니다.
즉 h2관련 코드를 제가 잘못작성했거나 아니면 다른이유로 오류가 발생한다는건데 문제점을 제대로 파악을 하기가 힘들어서 질문을 드립니다.
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Hikari.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.zaxxer.hikari.HikariDataSource]: Factory method 'dataSource' threw exception; nested exception is java.lang.IllegalStateException: Cannot load driver class: org.h2.driver
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.zaxxer.hikari.HikariDataSource]: Factory method 'dataSource' threw exception; nested exception is java.lang.IllegalStateException: Cannot load driver class: org.h2.driver
Caused by: java.lang.IllegalStateException: Cannot load driver class: org.h2.driver
Execution failed for task ':LibraryAppApplication.main()'.
> Process 'command 'C:/Program Files/Java/jdk-17/bin/java.exe'' finished with non-zero exit value 1
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
답변 1
0
안녕하세요, 승환님! 🙂 질문 남겨주셔서 감사합니다 ㅎㅎㅎ
남겨주신 내용으로 제가 파악 가능한 부분은
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Hikari.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.zaxxer.hikari.HikariDataSource]: Factory method 'dataSource' threw exception; nested exception is java.lang.IllegalStateException: Cannot load driver class: org.h2.driver
에서 org.h2.driver 를 찾지 못하고 있다는 부분입니다!
build.gradle 에서 H2 드라이버가 설정되어 있는지, gradle refresh가 잘 되었는지 확인해보시면 좋을 것 같고, 혹시나 계속해서 잘 안된다면 (스프링 버전에 따라 자동으로 버전을 잡아주지 못할 수 있습니다)
runtimeOnly 'com.h2database:h2'아래와 같이 명시적인 버전을 적어주시면 해결될 것 같습니다.
이러한 버전 목록은 https://mvnrepository.com/artifact/com.h2database/h2 에서 확인하실 수 있습니다.
runtimeOnly 'com.h2database:h2:2.2.224'
꼭 해결되셨으면 좋겠습니다. 감사합니다!! 😊
패키지 구분에 대해 궁금한게 있습니다
0
20
2
리액트 관련 질문이 있습니다.
0
64
2
스프링부트 버전
0
73
2
7강 강의를 들으려고 했는데 오류가 나서 서버가 안 켜지는거 같아요.
0
59
2
33강. UserLoanHistory의 관계성에 대한 질문
1
56
2
Java JDK 버전 문의의 건
0
132
2
ec2 에서 Linux버전이 달라져서 설치가 안되는것 같은데 자료 최신화좀 해주세요.
0
88
3
h2 console 접속했을 테이블 질문
1
65
1
ec2 서버에서 스프링 실행도 되고 인바운드 설정까지 했는데 index.html 안됨
0
75
2
15강. updateUser() 질문
0
55
2
깃허브 질
0
82
2
여기까지 다 끝냈다고 하셨는데
0
79
2
왜안될까요
0
70
2
MySQL 창이안ㄴ뜹니다
0
59
2
포스트맨
0
50
1
spring 개념적인 질문
0
71
2
인텔리제이 샘플코드 실행 안됨 오류
0
140
2
aws 배포할때 .env 파일에 저장한 환경변수에 관하여 여쭤볼게 있습니다
0
84
1
마이그레이션 오류입니다.
0
171
3
Whitelabel Error Page 오류가 났습니다.
0
163
2
안녕하십니까! 오류가 났습니다.. 도와주세요 ㅜㅜ
1
93
3
궁금한게 있습니다.
0
60
2
DTO 관련
0
70
2
궁금한게 있습니다!
0
68
2





