在我向 spring-data-cassandra 存储库接口添加@Retryable
注释后,现在应用程序无法启动并出现以下异常:
应用程序无法启动
The bean 'airingDao' could not be injected as a 'my.dao.AiringDao' because it is a JDK dynamic proxy that implements:
org.springframework.data.cassandra.repository.CassandraRepository
行动:
Consider injecting the bean as one of its interfaces or forcing the use of CGLib-based proxies by setting proxyTargetClass=true on @EnableAsync and/or @EnableCaching.
添加proxyTargetClass=true
到@EnableAsync
和@EnableCaching
,甚至到@EnableRetry(proxyTargetClass = true)
@EnableAspectJAutoProxy(proxyTargetClass = true)
但还是不行。
删除后@Retryable
,一切正常。
检查了代码,没有@Retryable
,在org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(String, Class<T>, Object[], boolean)
bean.getClass().getInterfaces()
(java.lang.Class<T>[]) [interface my.dao.AiringDao, interface
org.springframework.data.repository.Repository, interface
org.springframework.transaction.interceptor.TransactionalProxy, interface
org.springframework.aop.framework.Advised, interface
org.springframework.core.DecoratingProxy]
requiredType.isAssignableFrom(bean.getClass())
也是_true
但添加后@Retryable
:
bean.getClass().getInterfaces()
(java.lang.Class<T>[]) [interface
org.springframework.retry.interceptor.Retryable, interface
org.springframework.aop.SpringProxy, interface
org.springframework.aop.framework.Advised, interface
org.springframework.core.DecoratingProxy]
所以现在requiredType.isAssignableFrom(bean.getClass()))
是false
并getTypeConverter().convertIfNecessary(bean, requiredType)
抛出异常。
任何人都可以请帮助或提供一些线索如何解决它?谢谢你的帮助。