Related to https://github.com/spring-projects/spring-retry/issues/214
When using spring-retry with JPA repositories, the JPA repo proxy is (incorrectly) wrapped in a proxy that only implements Retryable
.
We get a strange error when trying to inject this bean:
The bean 'testRepository' could not be injected as a 'com.example.demo.TestRepository' because it is a JDK dynamic proxy that implements:
org.springframework.data.repository.CrudRepository
The logic here...
printer.printf("The bean '%s' could not be injected as a '%s' because it is a "
+ "JDK dynamic proxy that implements:%n", ex.getBeanName(), ex.getRequiredType().getName());
for (Class<?> requiredTypeInterface : ex.getRequiredType().getInterfaces()) {
printer.println("\t" + requiredTypeInterface.getName());
}
...simply appends the super-interface of TestRepository
(CrudRepository
) to the error message.
The actual exception message is:
org.springframework.beans.factory.BeanNotOfRequiredTypeException: Bean named 'testRepository' is expected to be of type 'com.example.demo.TestRepository' but was actually of type 'com.sun.proxy.$Proxy70'
$Proxy70
doesn't actually implement CrudRepository
- only Retryable
.
I believe the correct logic would be to use getActualType().getInterfaces()
in the for loop.