Search code examples
springh2embedded-database

Is it possible to add scripts dynamically with spring embedded database?


is it possible, to add scripts to the EmbeddedDatabase of Spring dynamically? I get for example 3 scripts per parameter, so i want to add these 3. The next time I only want to add 2 scripts. It will only used in development mode, but developers can decided themselves, which scripts they want to use, cause they want to test different data as another.

I hope you understand my question :)

Greetings!


Solution

  • May be something like:

    private DatabasePopulator databasePopulator() {
        final ResourceDatabasePopulator populator = new ResourceDatabasePopulator();
        populator.addScript(schemaScript);
        populator.addScript(dataScript);
        return populator;
    

    More information here