springboot整合mybatis bean注入失败

异常报文: 

Field adminDAO in com......service.impl.AdminServiceImpl required a bean of type 'com.....dao.AdminDAO' that could not be found.

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v2.1.5.RELEASE)

2019-05-25 23:39:27.645  INFO 31864 --- [           main] com.eszb.SprintbootdemoApplication       : Starting SprintbootdemoApplication on DESKTOP-6MD93CN with PID 31864 (D:\java\springboot-project\sprintbootdemo\target\classes started by Mr.Yu in D:\java\springboot-project\sprintbootdemo)
2019-05-25 23:39:27.649  INFO 31864 --- [           main] com.eszb.SprintbootdemoApplication       : No active profile set, falling back to default profiles: default
2019-05-25 23:39:28.523  INFO 31864 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8080 (http)
2019-05-25 23:39:28.540  INFO 31864 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2019-05-25 23:39:28.540  INFO 31864 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet engine: [Apache Tomcat/9.0.19]
2019-05-25 23:39:28.639  INFO 31864 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2019-05-25 23:39:28.639  INFO 31864 --- [           main] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 949 ms
2019-05-25 23:39:28.678  WARN 31864 --- [           main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'adminController': Unsatisfied dependency expressed through field 'adminService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'adminService': Unsatisfied dependency expressed through field 'adminDAO'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.eszb.dao.AdminDAO' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
2019-05-25 23:39:28.681  INFO 31864 --- [           main] o.apache.catalina.core.StandardService   : Stopping service [Tomcat]
2019-05-25 23:39:28.692  INFO 31864 --- [           main] ConditionEvaluationReportLoggingListener : 

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2019-05-25 23:39:28.763 ERROR 31864 --- [           main] o.s.b.d.LoggingFailureAnalysisReporter   : 

***************************
APPLICATION FAILED TO START
***************************

Description:

Field adminDAO in com.eszb.service.impl.AdminServiceImpl required a bean of type 'com.eszb.dao.AdminDAO' that could not be found.

The injection point has the following annotations:
	- @org.springframework.beans.factory.annotation.Autowired(required=true)


Action:

Consider defining a bean of type 'com.eszb.dao.AdminDAO' in your configuration.


Process finished with exit code 1

问题描述:这个异常描述是在service类里面用到的dao层接口,在注入dao层接口的时候,出现了异常,没有找到dao层的这个类,这个是由于spring没有扫到dao层的接口的原因,所以需要在启动的类上加上扫描dao层的类的注解,如下:

@MapperScan("com.eszb.dao")

此时就ok了

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值