---
title: "h2的baseDir"
author: "i2534"
date: "2011-11-11T16:38:11Z"
tags: []
categories: ["数据库"]
slug: "h2-basedir"
draft: false
lastmod: "2011-11-11T16:38:11Z"
id: 1254466
url: "https://i2534.iteye.com/blog/1254466"
---

使用h2 1.3.161.在web项目中.计划在Listener中启动h2的TcpServer.并设置数据库文件到WEB-INF下的h2文件夹下.

本来想的好好的,获取WEB-INF的地址,传给Server,使用baseDir,却无论如何都不行.

最后直接在启动Server前,把path设置进System.properties中,key为h2.baseDir.

然后不管是使用

jdbc:h2:file:db

还是

jdbc:h2:tcp://localhost/file:db

都可以正确找到路径了.