There is a problem bother me for several days.
I ran a Sprint Boot sample (downloaded from https://github.com/spring-projects/spring-boot/tree/master/spring-boot-samples/spring-boot-sample-data-jpa) in my eclipse IDE, and it started failed.
Caused by: java.lang.IllegalStateException: Cannot load driver class: org.h2.Driver
The log shows load h2 database driver failed.
I checked my pom.xml, and the h2database has been configured.
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>runtime</scope>
</dependency>
I checked Maven Dependencies
in Project explorer
, and the h2-1.4.196.jar
existed.
I pressed command + shift + T
, no class “org.h2.driver” shown.
I searched in baidu and google, and tried many ways, such as:
- Project -> Clean…
- Maven -> Update Project (Right click on my project)
But, it did NOT work!
I entered ~/.m2/repository/com/h2database/h2/1.4.196
and ls
, there were a file named h2-1.4.196.jar
.
I downloaded the same-named file from http://www.h2database.com/html/cheatSheet.html.
I found the file sizes are different!!!
I realized that the jar file was damaged.
I removed the old file, and moved the new file to the folder, update Maven project.
It finally worked.