H2DB 的默认 url 和凭据? [英] Default url and credentials for H2DB?

查看:31
本文介绍了H2DB 的默认 url 和凭据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为了进行单元测试,我在 springBoot 应用程序中添加了 H2DB.

I have added H2DB in my springBoot application for unit testing purpose.

在 application-test.properties 中我刚刚添加:

In application-test.properties I just added:

spring.datasource.name = h2db

spring.datasource.name = h2db

spring.h2.console.enabled = true

spring.h2.console.enabled = true

它工作正常,保存了值.

Its working fine, saving the values.

但是它是如何工作的,我该如何浏览这个数据库?

But how it is working and how can I browse this DB?

推荐答案

Spring Boot 应用中 H2 的默认属性是:

Default properties for H2 in Spring Boot application are:

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 自己创建这个数据库.

So it's not necessary to add them to your application.properties - Spring Boot create this DB itself.

如果您想直接从您的 IDE 访问您的 H2 DB,您必须进行此设置.

If you want to get access to your H2 DB right from your IDE you have to make this setup.

这篇关于H2DB 的默认 url 和凭据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆