-
Notifications
You must be signed in to change notification settings - Fork 41.1k
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
Condition evaluation report entry for a @ConditionalOnSingleCandidate that does not match due to multiple primary beans isn't as clear as it could be #30073
Comments
of course, the server can't be started at all due to missing EntityManagerFactory bean |
Thanks for the suggestion. The condition evaluation report (available by starting the app with Beyond that, I am not keen on treating this situation specially as it is not really any different to any other situation where auto-configuration backs off. |
If you have multiple |
Hi @snicoll, that's what I thought so, but drilling into evaluation report (or using TRACE) kind of counter-intiutive. We defined in this way. 2 @configuration classes having 2 DataSource defined, but one is @primary. (so these DataSource has the actual database connections) and another "hidden" DataSource defined in @configuration class (which the team not aware of), having @primary but prefix for @ConfigurationProperties not defined in anywhere. (this DataSource hence not used anywhere) |
The evaluation report is exactly meant for that kind of thing. If you expect a bean to be created, and it isn't, then that is the place to look at. Back to my original ask, thanks for the details but that's not the sample I was expecting and I am even more confused now. Is the "hidden" datasource defined as a bean ultimately? If it isn't, then the whole report needs to be revisited. For us to make progress, we'd need a sample that we can run ourselves that demonstrates what you've described. |
Total 3 they get defined in below manner, only properties for prefix App2 and App3 are the one that having
|
This will only happen if something injects a
With the example configuration, the condition evaluation report shows that
The message in the condition evaluation report isn't quite as good as the message of the |
hi @wilkinsona that's good enough. thanks! |
In the event there is multiple @primary DataSource but one with proper 'dataSource' naming, no EntityManagerFactory bean will be created at all.
This can only be seen when the logging info is set at TRACE level, to find out how many dataSource beans created, and causing this AutoConfiguration not "properly" configured.
Consider to either allow the
ConditionalOnSingleCandidate
annotation to add attribute whether to throw error or warn upon there is multiple @primary DataSource defined.Or to allow this AutoConfiguration to log warning message when detect multiple @primary DataSource beans
spring-boot/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.java
Line 64 in c755e0d
The text was updated successfully, but these errors were encountered: