我已经阅读了几乎所有关于 H2 控制台的问题,但没有找到解决方案。当我点击 URL 时,我收到了Whitelabel Error Pagehttp://localhost:8080/h2-console。我在我的项目中添加了以下依赖项:<dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-jpa</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency> <!-- https://mvnrepository.com/artifact/com.h2database/h2 --> <dependency> <groupId>com.h2database</groupId> <artifactId>h2</artifactId> <scope>runtime</scope>> </dependency></dependencies>application.propertiesspring.h2.console.enabled=truespring.datasource.url=jdbc:h2spring.datasource.driverClassName=org.h2.Driverspring.datasource.username=saspring.datasource.password=spring.jpa.database-platform=org.hibernate.dialect.H2Dialect
1 回答
紫衣仙女
TA贡献1839条经验 获得超15个赞
在应用程序属性中添加
spring.h2.console.path=/h2-console
H2 的属性
spring.datasource.url=jdbc:h2:mem:testdb;DB_CLOSE_DELAY=-1
spring.datasource.driverClassName=org.h2.Driver
spring.datasource.username=sa
spring.datasource.password=
spring.jpa.database-platform=org.hibernate.dialect.H2Dialect
spring.h2.console.path=/h2-console
DB_CLOSE_DELAY = -1 防止连接丢失
更新
对于直接来自 Spring Initialzr 的 Spring Boot 2.x:
devtools 默认是http://127.0.0.1:8080/h2-console/
POM: spring-boot-starter, h2, spring-boot-starter-web, spring-boot-devtools
没有 devtools - 你需要在属性中设置它:
spring.h2.console.enabled=true spring.h2.console.path=/h2-console
POM: spring-boot-starter, h2, spring-boot-starter-web
添加回答
举报
0/150
提交
取消