AbstractRoutingDataSource + JPA will not create a table except defaultTargetDataSource

I use JPA annotations (Hibernate implementation) to initialize my DB schema. And I follow the DYNAMIC DATASOURCE ROUTING article for implementing a dynamic data routing class.

However, I have two databases (2 data sources mapped). I set the first data source as defaultTargetDataSource. then run my application. When my application tries to access a second data source, say that the table does not exist. It seems AbstractRoutingDataSource is creating a table for the default data source, but other data sources.

Is there an idea to create a schema in all databases?

PS. I am using AbstractRoutingDataSource to implement my own database blocks.

+3
source share

All Articles