Skip to content

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

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

Closed
odrotbohm opened this issue Mar 31, 2016 · 2 comments
Assignees
Labels
type: enhancement A general enhancement
Milestone

Comments

@odrotbohm
Copy link
Member

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?

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Mar 31, 2016
@wilkinsona
Copy link
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
Copy link
Member Author

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
Labels
type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

5 participants