In application.properties:
spring.h2.console.enabled=true
spring.h2.console.path=/h2console/
In my security configuration class I added a bit more to the HttpSecurity configuration:
package com.example.demo;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
@Configuration
@EnableWebSecurity
public class SecurityConfiguration extends WebSecurityConfigurerAdapter{
@Override
protected void configure(HttpSecurity http) throws Exception{
http.authorizeRequests().antMatchers("/").permitAll().and()
.authorizeRequests().antMatchers("/h2console/**").permitAll();
http.csrf().disable();
http.headers().frameOptions().disable();
}
}