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
Starting from Spring-Boot 3.2.x the @SpyBean is not able to initialise MongoRepository bean of the generic type. #40234
Comments
The change in behavior is due to spring-projects/spring-data-commons@98f20a4. The move away from the Lines 258 to 261 in a3d62e0
This failed matching means that we don't find the existing bean and instantiating one fails as it's an interface. It's unfortunate that Framework doesn't find the factory bean when we ask for beans of a particular type: Lines 252 to 253 in a3d62e0
It doesn't find them as we are not permitting eager init so it only checks raw factory beans and not the beans created by those factory beans. Perhaps this could be improved when the bean definition has additional type information as it does in this case? In the absence of a change in Framework, when the object type attribute's is |
I've opened spring-projects/spring-framework#32649 to track a change on the Framework side that will hopefully get this working without changing anything in Boot. |
FYI, there are some improvements about repository definition's target type: Not sure Boot could benefit from it. |
public interface ExampleRepository<T extends AbstractData> extends MongoRepository<ExampleData, String> {
} I don't understand why |
We may get something in Framework 6.2 that helps with this. Until then, we'll have to refine our own matching. |
Issue
Starting from Spring-Boot 3.2.x the @SpyBean is not able to initialize MongoRepository bean of the generic type.
Please check the example project: https://github.com/pavlo-reshetniak/spybean-issue-example
How to reproduce
Result
Possible workaround
The text was updated successfully, but these errors were encountered: