Starting an H2 Database Server from Maven?

I was able to get it to work without using an external server just by adding the dependency to H2 via Maven and then using this bean:

<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
    <property name="driverClassName" value="org.h2.Driver"/>
    <property name="url" value="jdbc:h2:file:h2\db"/>
    <property name="username" value="sa"/>
    <property name="password" value=""/>        
</bean>

Then again, this required that I use a file-based DB instead of in-memory. But it does the trick.

Leave a Comment