Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
itzuimao opened this issue Jan 8, 2019 · 2 comments
Open

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

itzuimao opened this issue Jan 8, 2019 · 2 comments

Comments

@itzuimao
Copy link

itzuimao commented Jan 8, 2019

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

@Resource
ArticleDao articleDao;
@fang-yan-peng
Copy link

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

@itzuimao
Copy link
Author

itzuimao commented Jan 8, 2019

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

@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;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants