• java.lang.IllegalStateException: ApplicationEventMulticaster not initialized


    spring boot 项目启动报错:原因一般是注入了相同名字的service

     1 2018-08-16 17:53:19 com.gxcards.mes.MainWwwWeb:662 logStartupProfileInfo INFO: No active profile set, falling back to default profiles: default
     2 2018-08-16 17:53:19 org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext:582 prepareRefresh INFO: Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@63429932: startup date [Thu Aug 16 17:53:19 CST 2018]; parent: org.springframework.context.annotation.AnnotationConfigApplicationContext@764faa6
     3 2018-08-16 17:53:20 org.springframework.beans.factory.support.DefaultListableBeanFactory:828 registerBeanDefinition INFO: Overriding bean definition for bean 'restTemplate' with a different definition: replacing [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=restTemplateConfiguration; factoryMethodName=restTemplate; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [com/gxcards/mes/config/RestTemplateConfiguration.class]] with [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=mainGoodsService; factoryMethodName=restTemplate; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [com/gxcards/mes/MainGoodsService.class]]
     4 2018-08-16 17:53:20 org.springframework.beans.factory.support.DefaultListableBeanFactory:828 registerBeanDefinition INFO: Overriding bean definition for bean 'restTemplate' with a different definition: replacing [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=mainGoodsService; factoryMethodName=restTemplate; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [com/gxcards/mes/MainGoodsService.class]] with [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=mainWwwWeb; factoryMethodName=restTemplate; initMethodName=null; destroyMethodName=(inferred); defined in com.gxcards.mes.MainWwwWeb]
     5 2018-08-16 17:53:20 org.springframework.boot.SpringApplication:840 reportFailure ERROR: Application startup failed
     6 java.lang.UnsupportedOperationException
     7     at java.util.AbstractCollection.add(AbstractCollection.java:262)
     8     at java.util.AbstractCollection.addAll(AbstractCollection.java:344)
     9     at org.springframework.boot.web.servlet.ServletComponentScanRegistrar.updatePostProcessor(ServletComponentScanRegistrar.java:62)
    10     at org.springframework.boot.web.servlet.ServletComponentScanRegistrar.registerBeanDefinitions(ServletComponentScanRegistrar.java:48)
    11     at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsFromRegistrars(ConfigurationClassBeanDefinitionReader.java:352)
    12     at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForConfigurationClass(ConfigurationClassBeanDefinitionReader.java:143)
    13     at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitions(ConfigurationClassBeanDefinitionReader.java:116)
    14     at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:320)
    15     at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:228)
    16     at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:270)
    17     at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:93)
    18     at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:686)
    19     at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:524)
    20     at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122)
    21     at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:762)
    22     at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:372)
    23     at org.springframework.boot.SpringApplication.run(SpringApplication.java:316)
    24     at org.springframework.boot.SpringApplication.run(SpringApplication.java:1187)
    25     at org.springframework.boot.SpringApplication.run(SpringApplication.java:1176)
    26     at com.gxcards.mes.MainWwwWeb.main(MainWwwWeb.java:42)
    27 2018-08-16 17:53:20 org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext:987 doClose INFO: Closing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@63429932: startup date [Thu Aug 16 17:53:19 CST 2018]; parent: org.springframework.context.annotation.AnnotationConfigApplicationContext@764faa6
    28 2018-08-16 17:53:20 org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext:1005 doClose WARN: Exception thrown from LifecycleProcessor on context close
    29 java.lang.IllegalStateException: LifecycleProcessor not initialized - call 'refresh' before invoking lifecycle methods via the context: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@63429932: startup date [Thu Aug 16 17:53:19 CST 2018]; parent: org.springframework.context.annotation.AnnotationConfigApplicationContext@764faa6
    30     at org.springframework.context.support.AbstractApplicationContext.getLifecycleProcessor(AbstractApplicationContext.java:417)
    31     at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:1002)
    32     at org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:961)
    33     at org.springframework.boot.SpringApplication.handleRunFailure(SpringApplication.java:819)
    34     at org.springframework.boot.SpringApplication.run(SpringApplication.java:327)
    35     at org.springframework.boot.SpringApplication.run(SpringApplication.java:1187)
    36     at org.springframework.boot.SpringApplication.run(SpringApplication.java:1176)
    37     at com.gxcards.mes.MainWwwWeb.main(MainWwwWeb.java:42)
    38 2018-08-16 17:53:20 org.springframework.beans.factory.support.DefaultListableBeanFactory:581 destroyBean ERROR: Destroy method on bean with name 'org.springframework.boot.autoconfigure.internalCachingMetadataReaderFactory' threw an exception
    39 java.lang.IllegalStateException: ApplicationEventMulticaster not initialized - call 'refresh' before multicasting events via the context: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@63429932: startup date [Thu Aug 16 17:53:19 CST 2018]; parent: org.springframework.context.annotation.AnnotationConfigApplicationContext@764faa6
    40     at org.springframework.context.support.AbstractApplicationContext.getApplicationEventMulticaster(AbstractApplicationContext.java:404)
    41     at org.springframework.context.support.ApplicationListenerDetector.postProcessBeforeDestruction(ApplicationListenerDetector.java:97)
    42     at org.springframework.beans.factory.support.DisposableBeanAdapter.destroy(DisposableBeanAdapter.java:253)
    43     at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroyBean(DefaultSingletonBeanRegistry.java:578)
    44     at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroySingleton(DefaultSingletonBeanRegistry.java:554)
    45     at org.springframework.beans.factory.support.DefaultListableBeanFactory.destroySingleton(DefaultListableBeanFactory.java:961)
    46     at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroySingletons(DefaultSingletonBeanRegistry.java:523)
    47     at org.springframework.beans.factory.support.DefaultListableBeanFactory.destroySingletons(DefaultListableBeanFactory.java:968)
    48     at org.springframework.context.support.AbstractApplicationContext.destroyBeans(AbstractApplicationContext.java:1033)
    49     at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:1009)
    50     at org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:961)
    51     at org.springframework.boot.SpringApplication.handleRunFailure(SpringApplication.java:819)
    52     at org.springframework.boot.SpringApplication.run(SpringApplication.java:327)
    53     at org.springframework.boot.SpringApplication.run(SpringApplication.java:1187)
    54     at org.springframework.boot.SpringApplication.run(SpringApplication.java:1176)
    55     at com.gxcards.mes.MainWwwWeb.main(MainWwwWeb.java:42)
    56 Disconnected from the target VM, address: '127.0.0.1:61286', transport: 'socket'

    说是在项目中有了相同的 Overriding bean definition for bean 'restTemplate',原来是在我的这个项目的pom文件中引用了另一个项目,另一个项目也注入有restTemplate,导致启动报错。把本项目中的引用的另一个项目删除就解决了。

  • 相关阅读:
    Mysql 导入CSV数据 语句 导入时出现乱码的解决方案
    有用的 Mongo命令行 db.currentOp() db.collection.find().explain()
    MySql Host is blocked because of many connection errors; unblock with 'mysqladmin flush-hosts' 解决方法 -摘自网络
    MongoDB索引相关文章-摘自网络
    批量更新MongoDB的列。
    RabbitMQ 消费端 Client CPU 100%的解决办法
    php根据命令行参数生成配置文件
    php解释命令行的参数
    使用memcache对wordpress优化,提速
    python基础技巧综合训练题2
  • 原文地址:https://www.cnblogs.com/bfyq/p/9488943.html
Copyright © 2020-2023  润新知