官网左侧有一个Quickstart,即快速开始教程
Embedding H2 in an Application
This database can be used in embedded mode, or in server mode. To use it in embedded mode, you
need to:
- Add the| h2*.jar to the classpath (H2 does not have any dependencies)
- Use the JDBC driver class: org .h2 Driver
- The database URL jdbc:h2:-/test opens the database test in your user home directory
- A new database is automatically created
按照上面的提示进行如下操作
- 添加依赖:在maven仓库搜索h2找到“H2 Database Engine”点击进入,复制最新依赖到pom.xml
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>1.4.200</version>
<scope>test</scope>
</dependency>