The Spring Boot guide says I can get the H2 console but it's not working for me.
http://localhost:8080/h2/ Whitelabel Error Page This application has no explicit mapping for /error, so you are seeing this as a fallback. Wed Oct 26 12:31:46 BST 2016 There was an unexpected error (type=Not Found, status=404). No message available
I created an application.properties
file as follows
spring.h2.console.enabled=true
spring.h2.console.path=/h2
My project is based on this
The default path /h2-console
doesn't work either.
I found another answer where the problem is solved by adding to Application.java
:
@Bean
public ServletRegistrationBean h2servletRegistration() {
ServletRegistrationBean registration = new ServletRegistrationBean(new WebServlet());
registration.addUrlMappings("/h2/*");
return registration;
}
Everything in my application.properties
file is ignored. I have tried adding:
spring.datasource.url=jdbc:h2:file:~/portal;DB_CLOSE_ON_EXIT=FALSE
spring.datasource.username=sa
spring.datasource.password=
spring.datasource.driverClassName=org.h2.Driver
But the database is still created in memory only.
Your current location src\main\java\hello\application.properties
is the culprit. For 2 reasons.
src\main\java
are ignoredapplication.properties
in the root or config
directory or taken into account (by default). (See the reference guide). The fix is to simply move your application.properties
to src\main\resources
.