-
Notifications
You must be signed in to change notification settings - Fork 40.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Consider initialization of multiple datasources #13417
Comments
This is the expected behavior with the current implementation. The initializer currently only works with the So multiple datasource you'll currently need to use |
See also #9528 |
We have discussed the possibility to auto-configure multiple data sources and didn’t execute on it. For that reason, I think this issue should be closed. |
But with #9528 we may end up with an API that can be used to register a DataSource for initialisation. We'd then use that API for the auto-configured DataSource and make it available to users for use with their own, manually configured data sources. If anything, I could see this being or becoming a duplicate of #9528. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
See #15732 |
Closing in favor of #9528 |
Sample project in attach with failing test cases, run via mvnw test
Two datasources are configured, each with a schema and data init file, however only the schema and data initialization from the primary datasource is executed.
I would have expected the data/schema init files both would be executed in their respective configured datasource.
Main reason seems to be that the spring
DataSourceInitializerPostProcessor
requests aDataSourceInitializerInvoker
singleton which will then only execute intialization once.A second issue seems to be that the
DataSourceInitializerInvoker
does not check the DataSourceSchemaCreatedEvent source to match the current datasource, so it might react to the wrong one.Issue seems to be present from at least Spring Boot 2.0.0
demo.zip
The text was updated successfully, but these errors were encountered: