我在我的 springBoot 应用程序中添加了 H2DB 以进行单元测试。
在 application-test.properties 我刚刚添加:
spring.datasource.name = h2db
spring.h2.console.enabled = true
它工作正常,保存值。
但它是如何工作的,我如何浏览这个数据库?
我在我的 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,您必须进行此设置。