[英]Why does the H2 console in Spring Boot show a blank screen after logging in?
I'm using Spring Boot 1.4.1 with the H2 database.我在 H2 数据库中使用 Spring Boot 1.4.1。 I have enabled the H2 console as described in the reference guide by adding the following lines to my application.properties file:我按照参考指南中的描述启用了 H2 控制台,方法是将以下几行添加到我的 application.properties 文件中:
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":当我在 Chrome 53 for Windows 中转到 H2 控制台时,我可以看到登录页面并单击“测试连接”按钮会导致“测试成功”:
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 ).当我查看源代码时,我看到“抱歉,尚不支持 Lynx”(请参阅完整的源代码)。 The same thing happens in Firefox.同样的事情发生在 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
.我相信我使用的是正确的 JDBC URL,因为 4 个不同的人在这个问题上发布了你应该使用jdbc:h2:mem:testdb
。
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:根据一篇博文,如果你的项目中有spring-boot-starter-security
依赖,需要在SecurityConfig
类的configure
方法中添加一行,否则登录 H2 控制台后会看到一个空页面:
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我可以在 SecurityConfig 类中使用以下代码解决同样的问题
@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.我不知道这条线是做什么的,也许有经验的人可以解释一下。
将此添加到您的 application.properties
security.headers.frame=false
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.