Ivan Feliciano
09/29/2022, 11:10 PMapplication.yml
file as spring.datasource.[db1/db2].[options]
. Everything is working fine except I am not able to specify a separate schema.sql for each of them. I have tried by making a DataSourceInitializer bean but it is not getting executed (the bean is never even created).
A normal schema.sql
file works but is executed on all the databases.
@Bean(name = ["kvkDsInit"])
fun dsInit(@Qualifier("kvkDataSource") dataSource: DataSource): DataSourceInitializer {
val rdp = ResourceDatabasePopulator().apply {
addScript(ClassPathResource("schema-kvk.sql"))
}
return DataSourceInitializer().apply {
setDataSource(dataSource)
setDatabasePopulator(rdp)
}
}