Cannot load driver class: org.h2.Driver in spring boot application

It seems that your dependency

<dependency>
    <groupId>com.h2database</groupId>
    <artifactId>h2</artifactId>
    <scope>runtime</scope>
</dependency>

has to be in dependencies element, not in dependencyManagement. Just look at this. Or maybe you have a child artifact, in that case you must share another pom xml.


I was facing the same issue in IDEA IntellJ even after using the correct dependency in pom.xml. It boils down to IDE specific issue where it was not able to download h2 dependency. It worked after restarting the IDE.


I change it to 'compile' and it solved my problem.

        <dependency>
            <groupId>com.h2database</groupId>
            <artifactId>h2</artifactId>
            <version>1.4.200</version>
            <scope>compile</scope>
        </dependency>