为了账号安全,请及时绑定邮箱和手机立即绑定

在@Test 中测试方法是报错

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'com.ztes.demo.dao.AreaDaoTest': Unsatisfied dependency expressed through field 'areaDao'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.ztes.demo.dao.AreaDao' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)} 

测试报这样的错什么原因????请高手帮忙回答下。谢谢!!!

正在回答

7 回答

同学好,请确保你的package设置正确,com.ztes.demo.dao.AreaDao,我看截图里是com.imooc.demo.dao.AreaDao...

0 回复 有任何疑惑可以回复我~

-_-||-_-||-_-||-_-||-_-||-_-||-_-||-_-||加了@mapper 或者@repostory也不行,加了@Mapper public interface AreaDao{ }也不行  就是报错。。

0 回复 有任何疑惑可以回复我~

我也是,加了@mapper 或者@repostory也不行

0 回复 有任何疑惑可以回复我~

mapperscan的包路径改到.demo就不报错了

0 回复 有任何疑惑可以回复我~

我在网上查的这个问题的原因是接口无法被实例化到spring容器中,但是不知道怎么解决它

0 回复 有任何疑惑可以回复我~
#1

彭赛赛

@Mapper public interface AreaDao{ }
2019-02-26 回复 有任何疑惑可以回复我~

报名可以任意起啊,不一定非用imooc啊,谢谢

0 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消
SpringBoot+MyBatis搭建迷你小程序
  • 参与学习       91002    人
  • 解答问题       621    个

SpringBoot+MyBatis搭建小程序后台

进入课程

在@Test 中测试方法是报错

我要回答 关注问题
意见反馈 帮助中心 APP下载
官方微信