Today I have started to work with Spring Boot and I want to create Restfull services with Embedded Derby (Tomcat embedded done). How can I to manage of the autoconfigured DB and how to fill the DB ?
Use an EmbeddedDatabase
(which is a subinterface of DataSource
), as your dataSource
bean. You can use EmbeddedDatabaseBuilder
as a convenience class to help build the bean. You can use the builder to add your sql script, as well as set the EmbeddedDatabaseType
Something like
@Configuration
public class AppConfig {
@Bean
public EmbdeddedDataBase dataSource() {
return new EmbeddedDataBaseBuilder()
.addScripts("...", "...")
.setType(EmbeddedDataBaseType.DERBY).
.build();
}
}
EmbeddedBataBase
and other mentioned classes are in the spring jdbc jar. Also make sure you have your derby jar.