-
Notifications
You must be signed in to change notification settings - Fork 356
Application fails to start with 3.2.0-RC1 when configuring multiple datasources and dialects #1650
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
Comments
Sorry for inconvenience. This falls back on us as our current configuration model picks individual components from the application context instead of referring to a single component that could provide the dialect, mapping context and converter. With all that hassle, I suggest moving off |
Do you have any examples? Rather than that, is there any possibility of reverting this commit for now? |
The commit that changed behavior fixes a bug for users that want to use JDBC and R2DBC within a single application. Using a single What is the reason that you want to use different A sample to use @Configuration
public class MyConfig {
private final JdbcRepositoryFactory factory1;
private final JdbcRepositoryFactory factory2;
public MyConfig(…) {
this.factory1 = new JdbcRepositoryFactory(…);
this.factory2 = new JdbcRepositoryFactory(…);
}
@Bean
public MyRepository1 myRepository1() {
return factory1.getRepository(MyRepository1.class);
}
@Bean
public MyRepository2 myRepository2() {
return factory2.getRepository(MyRepository2.class);
}
} |
Thank you for the example. I didn't know repository beans could be defined in such a way. But It is a little cumbersome to create each repository bean by hand...
Oh, I didn't know it is OK to share |
Yeah, you're totally right with |
In 3.1.x, we can already configure multiple repositories with different dialects as I have shown here, so I'm afraid that people including me customizing repositories this way will suffer this regression when updating to 3.2.0. #687 is an enhancement to make it configurable more easily (In fact, I'm working on it now ;) |
In this repository, I've finally managed to configure repositories with multiple datasources and dialects (MySQL, PostgreSQL, Microsoft SQL Server), which goes like this:
@Qualifier
for each datasource@Qualifier
-ed beans for each datasourcerepositoryFactoryBeanClass
of@EnableJdbcRepositories
for each datasourceBut Bumping from 3.1.5 to 3.2.0-RC1, the application does not start by the following exception.
I've defined 3 JdbcMappingContext beans for each datasource, but the application looks to assume a single JdbcMappingContext bean. It is likely due to this commit that changed the behavior.
Adding
@Primary
to beans for a specific datasource will launch the application, but it results in using the wrong beans for repositories for another datasource.The text was updated successfully, but these errors were encountered: