In my spring boot application, I have added the below dependencies:
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>1.4.196</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
</dependency>
and then in my application.properties
i set:
spring.h2.console.enabled=true
management.security.enabled=false
But when i navigate to the uri:
http://localhost:8080/h2-console/login.do?jsessionid=cfc3b5595b531203d92134205e16127e
It complains with:
Whitelabel Error Page
This application has no explicit mapping for /error, so you are seeing this as a fallback.
Wed Sep 27 03:37:52 GMT-12:00 2017
There was an unexpected error (type=Not Found, status=404).
No message available
Why don't i have access to h2-console
?
There is one possible reason why h2-console
show that error. That is your files may not be organized in right way. I've also fetched this problem when I keep my Controller, Service, Repository and Model files all together in one package.
I've solved this problem by organizing them separately in their own packages like below
com.example.demo.controller
com.example.demo.service
com.example.demo.repository
com.example.demo.model
My application.properties file contains
spring.h2.console.enabled=true
spring.datasource.url=jdbc:h2:mem:testdb
spring.datasource.driverClassName=org.h2.Driver
spring.datasource.username=sa
spring.datasource.password=
spring.jpa.show-sql=true
spring.jpa.hibernate.ddl-auto=update
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.H2Dialect
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With