build.gradleに追記する
runtimeOnly 'com.h2database:h2'
implementation 'org.springframework.boot:spring-boot-starter-jdbc'
application.propertiesに追記する
# 接続先 実行するディレクトリを基準とした相対パス
# Eclipseからbootしたらプロジェクトルート直下にh2dbディレクトリが出来る
spring.datasource.url=jdbc:h2:./h2db/sample
# ユーザー名
spring.datasource.username=sa
# パスワード
spring.datasource.password=
# Webコンソールを有効にするか
spring.h2.console.enabled=true
# Webコンソールのパス
spring.h2.console.path=/h2-console
# remoteアクセスを有効にするか
spring.h2.console.settings.web-allow-others=false
# Driver名。h2のjarに含まれている
spring.datasource.driverClassName:org.h2.Driver
SpringBootを起動する
設定通りコンソールにアクセスする
schema.sqlとかをクラスパスにおいておけば起動時にデフォルトで入れてくれるのかな…??