Spring embeded database

Example 1, using H2

<jdbc:embeded-database id="datasource" type="H2">
   <jdbc:script location="classpath:jdbc/schema.sql"/>
   <jdbc:script location="classpath:jdbc/test-data.sql"/>
</jdbc:embeded>

Example 2,

<bean id="dataSource" 
class="org.springframework.jdbc.datasource.embeddedDatabaseFactoryBean">
     <property name="databasePopulator" ref="populator"/>
</bean>

<bean id="populator" 
class="org.springframework.jdbc.datasource.init.ResourceDatabasePopulator">
    <property name="scripts">
         <list>
                <value>classpath:jdbc/schema.sql</value>
         </list>
    </property>
</bean>


Spring embeded database

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.