记一次注入dao层mapper导致SpringBoot启动报错的问题
***************************
APPLICATION FAILED TO START
***************************
Description:
The bean 'orderMapper' could not be injected as a 'org.linlinjava.litemall.db.dao.LitemallOrderMapper' because it is a JDK dynamic proxy that implements:
Action:
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.
log.pattern_IS_UNDEFINED
Process finished with exit code 0
那么我这里的问题发现是我注入时用的注解是@Resource
@Resource
private LitemallOrderMapper orderMapper;
因为@Autowired默认按类型装配,而 @Resource优先按名称装配,如果使用@Resource时,可能有其他bean也是这个名字,所以就会出错。
那么我的解决办法是换个名字,当然也可以直接换注解为@Autowired
其他情况造成这个问题的解决办法,可以参考这篇文章
https://blog.csdn.net/w605283073/article/details/90454057