【错误记录1】Spring Boot 自动配置找不到applicationContext.xml中的beans

错误:

2019-07-27 11:02:01.785 WARN [main][AbstractApplicationContext.java:557] - Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'taskManagerDelegateImpl': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'requestDao' available
2019-07-27 11:02:01.785 INFO [main][DirectJDKLog.java:173] - Stopping service [Tomcat]
2019-07-27 11:02:01.816 INFO [main][ConditionEvaluationReportLoggingListener.java:142] - 

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2019-07-27 11:02:02.019 ERROR [main][LoggingFailureAnalysisReporter.java:42] - 

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

Description:

A component required a bean named 'requestDao' that could not be found.


Action:

Consider defining a bean named 'requestDao' in your configuration.

查了网上的解决方法,在web.xml中添加

   
        contextConfigLocation
        classpath*:applicationContext.xml
    

    
        org.springframework.web.context.ContextLoaderListener
    

还是没用

最后在Application.java中添加注解:

@SpringBootApplication(exclude = {MongoAutoConfiguration.class, MongoDataAutoConfiguration.class })
@ImportResource(locations = {"classpath:applicationContext.xml" })

再一个是因为application.properties中mongo用户名及密码没有配置,添加配置即可

mongo.replicaSet=localhost:27017
mongo.fixbot.username=root
mongo.fixbot.dbname=mymongo
mongo.fixbot.password=root

你可能感兴趣的:(【错误记录1】Spring Boot 自动配置找不到applicationContext.xml中的beans)