H2控制台在H2数据库中抛出webAllowOthers错误

cha*_*nya 7 java h2 spring-data spring-data-jpa spring-boot

当我尝试使用heruko加载我的h2控制台时,我正在使用heruko来部署我的应用程序它正在抛出一个错误说.

H2控制台很抱歉,此服务器上禁用了远程连接('webAllowOthers').

我在application.properties文件中使用以下设置

jdbc:h2:tcp://localhost/~/test
spring.datasource.platform=h2
spring.datasource.url=jdbc:h2:mem:Roomy;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE
spring.datasource.driverClassName=org.h2.Driver
spring.datasource.username=sa
spring.datasource.password=
spring.jpa.database-platform=org.hibernate.dialect.H2Dialect
spring.h2.console.enabled = true 
spring.h2.console.settings.trace=true 
spring.h2.console.settings.web-allow-others=true
Run Code Online (Sandbox Code Playgroud)

我做了一些谷歌并添加了.h2.server.properties

#H2 Server Properties
1=Generic H2 (Memory)|org.h2.Driver|jdbc:h2:mem:Roomy;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE|sa
webAllowOthers=true
tcpAllowOthers=true
webPort=8082
webSSL=false
Run Code Online (Sandbox Code Playgroud)

请提一下我做错了什么,我无法查看h2控制台可以有人帮忙.这个cosole工作正常在本地和heroku数据库工作没有问题,但无法查看控制台.任何帮助会非常感激的.

谢谢Chaitanya

小智 16

在application.properties中,添加以下设置.

"spring.h2.console.settings.web-允许,他人=真"

在我的情况下,它的工作原理.


Sem*_*urt 11

对于那些使用 application.yml 格式的人

spring:
  h2:
    console:
      enabled: true
      settings:
        web-allow-others: true
Run Code Online (Sandbox Code Playgroud)


小智 7

停止您的项目并添加到您的application.properties

spring.h2.console.enabled=true
spring.h2.console.settings.web-allow-others=true
Run Code Online (Sandbox Code Playgroud)

然后运行 ​​main 并重新加载浏览器。