【发布时间】:2021-06-26 17:05:02
【问题描述】:
我试图在我的 Spring Boot 应用程序上打开我的 h2-console,但它给了我“Whitelabel Error Page”。 我已经配置了我的 application.properties 文件
spring.h2.console.enabled=true
spring.datasource.platform=h2
spring.datasource.url=jdbc:h2:mem:testdb
为 h2 db 添加了依赖项:
<!-- https://mvnrepository.com/artifact/com.h2database/h2 -->
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>1.4.200</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
</dependency>
尝试重建项目并检查 https 自动重定向
【问题讨论】:
-
也许尝试将此
spring.h2.console.path=/h2-console添加到您的application.properties并通过http://localhost:port/h2-console访问它我还注意到您依赖于test scope???也许将其更改为runtime -
删除了测试范围,我将其添加到属性仍然无法正常工作...之前尝试使用完整的 url,它看起来不是因为谷歌浏览器上的 https 重定向问题
-
还有一个问题,为什么
h2有两个依赖项?我只会保留<dependency> <groupId>com.h2database</groupId> <artifactId>h2</artifactId> <scope>runtime</scope> </dependency> -
runtime 解决了问题.. 对不起,如果这是一个愚蠢的问题,但我可以标记评论,就像我可以标记我解决了问题的答案...如果不写所有这些回答亚里士多德,这样我就可以标记它并给你投票:) -
我也会写一个答案。所以其他人可以找到它:) 很高兴我帮助了