Spring Boot JPA H2 Console not running, application.properties file ignored
Another possible cause for this problem, is if you're using spring security.
In that case, you may want to add a specific permission to the h2-console URL you defined.
For example, for the default h2-console configuration (without a spring.h2.console.path
property), you will add this inside your WebSecurityConfigurerAdapter extending class:
@Override
protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests()
.antMatchers("/h2-console/**").permitAll()
.anyRequest().authenticated();
http.headers().frameOptions().sameOrigin();
}
Please also note that line at the end - http.headers().frameOptions().sameOrigin();
.
It's needed to prevent a Whitelable page error when logging in to the console.
This is described also here.
Your current location src\main\java\hello\application.properties
is the culprit. For 2 reasons.
- Non java resources in
src\main\java
are ignored - only
application.properties
in the root orconfig
directory or taken into account (by default). (See the reference guide).
The fix is to simply move your application.properties
to src\main\resources
.
Check if you set a base path in application.properties.
For example, if you have a setting
server.contextPath=/api
You access the h2 Console under
http://localhost:8080/api/h2-console
Obvious, but that was it for me