spring配置初始化出错

昨天配置maven项目的时候,报了一个错误。

警告: Exception thrown from LifecycleProcessor on context close
java.lang.IllegalStateException: LifecycleProcessor not initialized - call 'refresh' before invoking lifecycle methods via the context: Root WebApplicationContext: startup date [Thu Dec 14 23:56:52 CST 2017]; root of context hierarchy
    at org.springframework.context.support.AbstractApplicationContext.getLifecycleProcessor(AbstractApplicationContext.java:416)
    at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:997)
    at org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:956)
    at org.springframework.web.context.ContextLoader.closeWebApplicationContext(ContextLoader.java:581)
    at org.springframework.web.context.ContextLoaderListener.contextDestroyed(ContextLoaderListener.java:116)
    at org.apache.catalina.core.StandardContext.listenerStop(StandardContext.java:4889)
    at org.apache.catalina.core.StandardContext.stopInternal(Stan

相关错误信息

 initialized - call 'refresh' before invoking lifecycle methods via the context: Root WebApplicationContext: startup date
先来看一下百度翻译,spring初始化错误

接着去网上找了好久都没有一个好的答案,各类说法都不统一。

有说缺少jar包,有说jdk版本不对,还有说清理下项目重启就可以了。

但是试了一晚上后都不能解决问题。
最后终于在这里找到了问题的原因


Caused by: org.springframework.context.annotation.ConflictingBeanDefinitionException: Annotation-specified bean name 'adminUserRoleService' for bean class [com.rupeng.service.AdminUserRoleService] conflicts with existing, non-compatible bean definition of same name and class [com.rupeng.service.copy.AdminUserRoleServic

提示
 Annotation-specified bean name 'adminUserRoleService' for bean class [com.rupeng.service.AdminUserRoleService] conflicts with existing, non-compatible bean definition of same name and class [com.rupeng.service.copy.AdminUserRoleServic



找到问题存在两个service包冲突,删除copy文件后项目启动成功。

这个错误告诉我们,出了问题查看根异常有多么重要。
也就是Caused by这句话。然后去检查相应的错误就可以了





原文地址:https://www.cnblogs.com/a986771570/p/8041412.html