美文网首页
【错误记录1】Spring Boot 自动配置找不到applic

【错误记录1】Spring Boot 自动配置找不到applic

作者: Pig_Y | 来源:发表于2019-07-27 11:52 被阅读0次

    错误:

    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
    

    相关文章

      网友评论

          本文标题:【错误记录1】Spring Boot 自动配置找不到applic

          本文链接:https://www.haomeiwen.com/subject/qsvsrctx.html