我在 springBoot 应用程序中添加了 H2DB 以进行单元测试。
在 application-test.properties 我刚刚添加:
spring.datasource.name = h2db
spring.h2.console.enabled = true
它工作正常,保存值。
但是它是如何工作的,我如何浏览这个数据库?
最佳答案
Spring Boot 应用程序中 H2 的默认属性是:
spring.datasource.url=jdbc:h2:mem:testdb
spring.datasource.driverClassName=org.h2.Driver
spring.datasource.username=sa
spring.datasource.password=
spring.jpa.database-platform=org.hibernate.dialect.H2Dialect
所以没有必要将它们添加到您的
application.properties
- Spring Boot 自己创建这个数据库。如果你想直接从你的 IDE 访问你的 H2 DB,你必须让 this setup .
关于spring-boot - H2DB 的默认 URL 和凭据?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45925770/