异常报文:
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了