For prototyping and test environments, it is a good idea to use Java-based embedded databases to quickly start up the project and configure easily. They are lightweight and easily testable. Spring supports the HSQL, H2, and Derby database engines for that purpose natively. Here is a sample DataSource
configuration for an embedded HSQL database:
@Bean DataSource getHsqlDatasource() { return new EmbeddedDatabaseBuilder().setType(EmbeddedDatabaseType.HSQL) .addScript("db-scripts/hsql/db-schema.sql") .addScript("db-scripts/hsql/data.sql") .addScript("db-scripts/hsql/storedprocs.sql") .addScript("db-scripts/hsql/functions.sql") .setSeparator("/").build(); }
The XML version of this would look like the following code:
<jdbc:embedded-database id="dataSource" type="HSQL"> <jdbc:script location="classpath:db-scripts/hsql/ db-schema.sql" /> . . . </jdbc:embedded-database>