【错误记录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中添加

   <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>classpath*:applicationContext.xml</param-value>
    </context-param>

    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>

还是没用

最后在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
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容