在启动springboot时,autowired自动注入报错,

 

2017-05-26 15:23:05.761  WARN 46372 --- [           main] ationConfigEmbeddedWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'mongoTest': Unsatisfied dependency expressed through field 'mongoDaoTest'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException)}
2017-05-26 15:23:05.764  INFO 46372 --- [           main] o.apache.catalina.core.StandardService   : Stopping service Tomcat
2017-05-26 15:23:05.789  INFO 46372 --- [           main] utoConfigurationReportLoggingInitializer : 

Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled.
2017-05-26 15:23:05.891 ERROR 46372 --- [           main] o.s.b.d.LoggingFailureAnalysisReporter   : 

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

Description:

Field mongoDaoTest in mongo.MongoTest required a bean of type 'mongo.MongoDaoTest' that could not be found.


Action:

Consider defining a bean of type 'mongo.MongoDaoTest' in your configuration.

 

会提示注入失败,可以尝试把@EnableAutoConfiguration注解换成@SpringBootApplication;

@SpringBootApplication 注解效果等同于 @Configuration,@EnableAutoConfiguration 及 @ComponentScan 这三个注解一起使用,所以不要在 Controller 上面添加 @EnableAutoConfiguration 

相关文章:

  • 2021-08-09
  • 2021-12-07
  • 2021-08-20
  • 2021-05-24
  • 2022-12-23
  • 2022-01-15
  • 2021-08-07
  • 2022-01-08
猜你喜欢
  • 2022-12-23
  • 2022-03-07
  • 2022-12-23
  • 2021-11-12
  • 2021-09-08
  • 2022-02-05
  • 2022-02-12
相关资源
相似解决方案