[solved] h2 database console not working after using spring security

It’s a common problem when you are working on spring boot security with an in-memory database like the h2 database. Spring security protected every routes/apis by default that’s why we can’t visit the h2 database console. SO, this is a quick solution to get rid of. Hope it helps you.

 

Added these two properties in your application. properties file:

 spring.h2.console.enabled=true
 spring.h2.console.path=/h2 

And finally, go to your overridden configure class and configure it with:

 @Override
 protected void configure(HttpSecurity http) throws Exception {

  // making H2 console working
     http.headers().frameOptions().disable();
     http.authorizeRequests().antMatchers("/h2/**").permitAll();

 }

Leave a Reply