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

  • Post author:
  • Post category:Bugs
  • Post comments:0 Comments
  • Post last modified:November 3, 2021
  • Reading time:1 mins read

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

 

Added this 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