Skip to content

spring dbunit servlet module

excilys edited this page Aug 12, 2011 · 11 revisions

This module provides a ServletContextListener for loading and unloading DBUnit DataSets on web application startup and shutdown.

For example, this can be useful when developing a prototype where database content needs to be refreshed periodically.

How?

Quick start:

Declare the Listener in your web.xml

<listener>
	<listener-class>com.excilys.ebi.spring.dbunit.servlet.DataLoaderListener</listener-class>
</listener>

In this case, the engine will load a file named dataSet.xml located at the classpath root.

Custom configuration:

Defaults can be overridden thanks to context params in the web.xml :

<context-param>
	<!-- the DataSet files, comma separated -->
	<param-name>spring.dbunit.dataSets</param-name>
	<param-value>classpath:dataSet.xml</param-value>
</context-param>
Clone this wiki locally