mango-spring-boot-starter icon indicating copy to clipboard operation
mango-spring-boot-starter copied to clipboard

如何在Controller中使用注解实例化dao

Open itzuimao opened this issue 6 years ago • 2 comments
trafficstars

MyBatis可以通过如下代码注解自动实例化对象,请问mango如何实现相同的写法

@Resource
ArticleDao articleDao;

itzuimao avatar Jan 08 '19 12:01 itzuimao

把dao所在的包路径配置上,会自动扫描包下的dao并注入到spring中 mango: scan-package: com.test.dao

fang-yan-peng avatar Jan 08 '19 12:01 fang-yan-peng

非常感谢您能在百忙之中抽空回答我的问题,问题原因已经找到,是我代码写法的问题,与框架无关。 我的代码是

@Resource
NewArticleDao articleDao;

提示

Description:

The bean 'articleDao' could not be injected as a 'cn.shiche.web.dao.NewArticleDao' 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.

代码的正确写法应该是

@Resource
NewArticleDao newArticleDao;

itzuimao avatar Jan 08 '19 12:01 itzuimao