Hi, I have a multi database setup in Spring Boot, ...
# spring
i
Hi, I have a multi database setup in Spring Boot, each are in the
application.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.
Copy code
@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)
        }
    }