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

Using multiple embedded databases requires a lot of manual configuration exclusions #5541

Closed
odrotbohm opened this Issue Mar 31, 2016 · 2 comments

Comments

Projects
None yet
5 participants
@odrotbohm
Member

odrotbohm commented Mar 31, 2016

If multiple embedded DataSources are declared, one needs to explicitly disable the DataSourceAutoConfiguration and DataSourceTransactionManagerAutoConfiguration as can be seen here. They fail as they rely on unique DataSource instances to be present.

Can we let the simply opt out of being applied if multiple DataSources are present?

@wilkinsona

This comment has been minimized.

Member

wilkinsona commented Mar 31, 2016

on needs to explicitly disable the DataSourceAutoConfiguration and DataSourceTransactionManagerAutoConfiguration as can be seen here

AFAIK, that isn't strictly accurate. You can use multiple datasources as long as one of them is marked as @Primary without excluding either DataSourceAutoConfiguration or DataSourceTransactionManagerAutoConfiguration. You can see this in action in @snicoll's demo application.

That said, I expected this to be further improved by #2784 so that you could choose not to have a primary datasource and everything that worked with a single datasource would back off. That's not the case, though. @snicoll did you discover something that meant that using @ConditionalOnSingleCandidate wouldn't work in DataSourceTransactionManagerAutoConfiguration?

@odrotbohm

This comment has been minimized.

Member

odrotbohm commented Mar 31, 2016

I see. The point here is that making one DataSource the primary one can be a source of errors as you could @Transactional (without an explicit qualifier) by accident and thus run transactions on the "wrong" one. In the scenario I have here, both DataSources should be treated equally and not referring to one explicitly is rather considered an error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment