1

I am trying to open my h2-console on my spring boot app, but its giving me "Whitelabel Error Page". I have configured my application.properties file

spring.h2.console.enabled=true
spring.datasource.platform=h2
spring.datasource.url=jdbc:h2:mem:testdb

Added dependencies for h2 db:

 <!-- https://mvnrepository.com/artifact/com.h2database/h2 -->
            <dependency>
                <groupId>com.h2database</groupId>
                <artifactId>h2</artifactId>
                <version>1.4.200</version>
                <scope>test</scope>
            </dependency>
        <dependency>
            <groupId>com.h2database</groupId>
            <artifactId>h2</artifactId>
        </dependency>

tried rebuilding project and checked for https automatic redirecting

TomeVersic
  • 113
  • 1
  • 9
  • Maybe try to add this `spring.h2.console.path=/h2-console` to your `application.properties` and access it by `http://localhost:port/h2-console` I also notice that you have your dependency on `test scope` ??? Maybe change it to `runtime` – Aris Mar 30 '21 at 16:49
  • removed test scope and i added that to properties still not working... tried using full url before and it looks its not because of https redirecting problem on google chrome – TomeVersic Mar 30 '21 at 16:53
  • One more question why you have two dependencies for `h2`? I would keep only the the ` com.h2database h2 runtime ` – Aris Mar 30 '21 at 16:56
  • runtime solved problem .. sry if this is stupid question but can i mark comment same like i can mark answers that i solved problem... if not write all of that to answer Aristotle so i can mark it and give you upvote :) – TomeVersic Mar 30 '21 at 17:02
  • I will write an answer as well. So someone else could find it :) glad I helped – Aris Mar 30 '21 at 17:03
  • one more question why it doesnt want to connect now when it showed – TomeVersic Mar 30 '21 at 17:05
  • so when i try to connect to it using default url it gives me this "A file path that is implicitly relative to the current working directory is not allowed in the database URL "jdbc:h2:jdbc:h2:mem:testdb;FORBID_CREATION=TRUE". Use an absolute path, ~/name, ./name, or the baseDir setting instead. [90011-200] 90011/90011" @Aristotle – TomeVersic Mar 30 '21 at 17:05
  • I believe that this will help [stackoverflow-thread](https://stackoverflow.com/questions/30596150/how-to-use-a-path-relative-to-project-root-to-h2-db-file-configuration-with-play) – Aris Mar 30 '21 at 17:09

2 Answers2

1

By adding a dependency with <scope>test</scope> it indicates that the dependency is not required for normal use of the application, and is only available for the test compilation and execution phases

So change it to runtime because this scope indicates that the dependency is not required for compilation, but is for execution. Maven includes a dependency with this scope in the runtime and test classpaths, but not the compile classpath.

This will solve your issue:

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

You can read more about scopes here

Aris
  • 984
  • 8
  • 22
0

Change your H2 Dependency from test to runtime

    <dependency>
        <groupId>com.h2database</groupId>
        <artifactId>h2</artifactId>
        <scope>runtime</scope>
    </dependency>
B Sangappa
  • 574
  • 4
  • 8