spring-framework
spring-framework copied to clipboard
Improved error message for BeanNotOfRequiredTypeException
I'm using Spring 5.3.22 with Boot 2.7.3. I've been doing some configuration refactoring using Spring Integration, and I made a change that is causing my application startup to fail with a BeanNotOfRequiredTypeException; the bean is expected to be a MessageChannel but is a proxy for my gateway business interface instead.
The error message for BeanNotOfRequiredTypeException tells me what the expected and actual bean types are but not where the bean was trying to be injected. In my case, the problem is presumably that some dependent bean needs to be cleaned up so that has the correct expectation, but it's not clear which autowiring point caused the problem.
It would be useful for this case to identify the autowiring target when the failure occurred; perhaps AbstractAutowireCapableBeanFactory.createBean could catch and wrap the exception with further context?