4
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Spring Boot の組み込みDB(h2database)を永続化する設定

Posted at

設定

下記の設定を追加してください。

application.yml
spring:
    datasource:
        url: jdbc:h2:./.data/h2/db;MODE=PostgreSQL

./.data/h2/dbはデータの格納先なので、任意のディレクトリを指定可能。
プロジェクト内部にデータベースを格納する場合は、バージョン管理から除外してください。(.gitignoreファイルに/.data/を追加)

GradlebootRunタスクを実行して成功した場合は、./.data/h2/db.mv.dbが作成されます。

参考

以上

4
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?