Skip to content

spring dbunit servlet module

slandelle edited this page Mar 21, 2012 · 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.

Configuration customization:

Defaults can be overridden with a com.excilys.ebi.spring.dbunit.config.DataSetConfiguration instance declared in the Spring ApplicationContext. Make sure to declare the org.springframework.web.context.ContextLoaderListener before.

Advanced features

Multiple DataSets support

One can specify multiple DataSet locations. In this case, corresponding DataSets will be played in reverse order during shutdown phase so that they'll behave nicely if they depend on each other.

Clone this wiki locally