Spring embeded database

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>


Write a Reply or Comment

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