Skip to content

Latest commit

 

History

History
64 lines (39 loc) · 1.82 KB

databases-h2.md

File metadata and controls

64 lines (39 loc) · 1.82 KB
status impl-variants
released
true

Using H2 for Development in CAP Java

For local development and testing, CAP Java supports the H2 database, which can be configured to run in-memory.

Learn more about features and limitations of using CAP with H2{.learn-more}

::: warning Not supported for CAP Node.js. :::

[[toc]]

Setup & Configuration {.impl .java}

Using the Maven Archetype {.impl .java}

When a new CAP Java project is created with the Maven Archetype or with cds init, H2 is automatically configured as in-memory database used for development and testing in the default profile.

Manual Configuration {.impl .java}

To use H2, just add a Maven dependency to the H2 JDBC driver:

<dependency>
  <groupId>com.h2database</groupId>
  <artifactId>h2</artifactId>
  <scope>runtime</scope>
</dependency>

Next, configure the build to create an initial schema.sql file for H2 using cds deploy --to h2 --dry.

In Spring, H2 is automatically initialized as in-memory database when the driver is present on the classpath.

Learn more about the configuration of H2 {.learn-more}

Features {.impl .java}

CAP supports most of the major features on H2:

Learn about features and limitations of H2{.learn-more}