'Spring boot AbstractDataSourceBasedMultiTenantConnectionProviderImpl as well as a shared database

I currently have multi tennancy database working by implmenting AbstractDataSourceBasedMultiTenantConnectionProviderImpl. This is working great thankfully. Now I must add a database to the mix that can be shared to with all tennants.

I have attempted adding multiple datasources, I added a new datasource config and things like that. I see in debug the connection string is created correctly with the details specified in the application properties file.

The problems start on any attempt to read data from the shared database. No matter what I do the getConnection function is called in the AbstractDataSourceBasedMultiTenantConnectionProviderImpl and changes the datasource connection string to the tennanted db.

Is there a way to check the datasource coming in and validate it if its going to the shared db or am I missing somthing simple here?



Solution 1:[1]

I solved this. It all came down to packaging. I needed to be more explicit on the packages being scanned and scan the entities explicitly as well.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 John m