问题
@Resourceprivate TemplatePlatformMallExtMapper templatePlatformMallMapper;
当templatePlatformMallMapper同时存在的时候,使用@Resource注入会启动报错。
2021-12-22 15:15:03.774 ERROR [bmp-prm-service,,,] 25444 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter :***************************APPLICATION FAILED TO START***************************Description:The bean 'templatePlatformMallMapper' could not be injected as a 'com.vevor.prm.mapper.template.platform.TemplatePlatformMallExtMapper' because it is a JDK dynamic proxy that implements:com.vevor.prm.mapper.template.platform.TemplatePlatformMallMapperAction: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.
原因
当用`@Resource`注入类的时候,他会优先按照名称去注入,所以当命名为`templatePlatformMallMapper`会首先查找`TemplatePlatformMallMapper`这个类而不是`TemplatePlatformMallExtMapper`这个类,所以启动报错 。
解决办法
- 换为@Autowired注入
- 注入时候的
templatePlatformMallMapper变量名称修改为其他未存在的类名驼峰命名,如templatePlatformMallExtMapper
