I'm using Spring Boot 1.4.1 with the H2 database. I have enabled the H2 console as described in the reference guide by adding the following lines to my application.properties file:
spring.h2.console.enabled=true
spring.h2.console.path=/h2
When I go to the H2 console in Chrome 53 for Windows, I can see the login page and clicking the "Test Connection" button results in "Test successful":
But when I click on the "Connect" button, the screen turns completely blank. When I view the source, I see "Sorry, Lynx not supported yet" (see the full source). The same thing happens in Firefox.
Why is that happening? I believe I am using the correct JDBC URL, as 4 different people posted on this question that you should use jdbc:h2:mem:testdb
.
Spring Boot can auto-configure H2 database browser-based console for us. To enable the console we need to set property spring.h2.console.enabled to true (default is false, Spring Boot version 2.0.2). By default the console can be accessed at URI /h2-console which can be changed by spring.h2.console.path property.
If you’ve enabled Spring Security in your Spring Boot application, you will not be able to access the H2 database console. With its default settings under Spring Boot, Spring Security will block access to H2 database console. To enable access to the H2 database console under Spring Security you need to change three things:
Default console logging Spring boot internally uses apache’s common logging and uses logback as default logging provider. If we do not make any logging specific configuration, still we see lots of logging output to console which is good enough for POC (proof of concept) purposes.
It stores data in memory, not persist the data on disk. Here we will be discussing how can we configure and perform some basic operations in Spring Boot using H2 Database. Some of the main features of the H2 Database are:
According to a blog post, a line needs to be added to
the configure
method of the SecurityConfig
class if you have the spring-boot-starter-security
dependency in your project, otherwise you will see an empty page after logging into the H2 console:
http.headers().frameOptions().disable();
I added that line and it solved the problem.
Alternatively, the following line can be used (as mentioned here):
http.headers().frameOptions().sameOrigin();
I can resolve the same problem using the following code in my SecurityConfig class
@Override
protected void configure(HttpSecurity http) throws Exception {
bla();
bla();
http.headers().frameOptions().sameOrigin();
}
I don't know what this line does, maybe someone with more experience can explain it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With