• tomcat启动报错:Bean name 'XXX' is already used in this <beans> element


      如题,tomcat容器启动时加载spring的bean,结果报错如下:

    六月 28, 2017 9:02:25 上午 org.apache.tomcat.util.digester.SetPropertiesRule begin
    警告: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:ms-selection' did not find a matching property.
    六月 28, 2017 9:02:25 上午 org.apache.catalina.startup.VersionLoggerListener log
    信息: Server version:        Apache Tomcat/8.5.13
    六月 28, 2017 9:02:25 上午 org.apache.catalina.startup.VersionLoggerListener log
    信息: Server built:          Mar 27 2017 14:25:04 UTC
    六月 28, 2017 9:02:25 上午 org.apache.catalina.startup.VersionLoggerListener log
    信息: Server number:         8.5.13.0
    六月 28, 2017 9:02:25 上午 org.apache.catalina.startup.VersionLoggerListener log
    信息: OS Name:               Windows 7
    六月 28, 2017 9:02:25 上午 org.apache.catalina.startup.VersionLoggerListener log
    信息: OS Version:            6.1
    六月 28, 2017 9:02:25 上午 org.apache.catalina.startup.VersionLoggerListener log
    信息: Architecture:          amd64
    六月 28, 2017 9:02:25 上午 org.apache.catalina.startup.VersionLoggerListener log
    信息: Java Home:             D:wulinfengJavajdk1.8.0_131jre
    六月 28, 2017 9:02:25 上午 org.apache.catalina.startup.VersionLoggerListener log
    信息: JVM Version:           1.8.0_131-b11
    六月 28, 2017 9:02:25 上午 org.apache.catalina.startup.VersionLoggerListener log
    信息: JVM Vendor:            Oracle Corporation
    六月 28, 2017 9:02:25 上午 org.apache.catalina.startup.VersionLoggerListener log
    信息: CATALINA_BASE:         E:workspace.metadata.pluginsorg.eclipse.wst.server.core	mp0
    六月 28, 2017 9:02:25 上午 org.apache.catalina.startup.VersionLoggerListener log
    信息: CATALINA_HOME:         D:wulinfeng	omcatapache-tomcat-8.5.13
    六月 28, 2017 9:02:25 上午 org.apache.catalina.startup.VersionLoggerListener log
    信息: Command line argument: -agentlib:jdwp=transport=dt_socket,suspend=y,address=localhost:55079
    六月 28, 2017 9:02:25 上午 org.apache.catalina.startup.VersionLoggerListener log
    信息: Command line argument: -Dcatalina.base=E:workspace.metadata.pluginsorg.eclipse.wst.server.core	mp0
    六月 28, 2017 9:02:25 上午 org.apache.catalina.startup.VersionLoggerListener log
    信息: Command line argument: -Dcatalina.home=D:wulinfeng	omcatapache-tomcat-8.5.13
    六月 28, 2017 9:02:25 上午 org.apache.catalina.startup.VersionLoggerListener log
    信息: Command line argument: -Dwtp.deploy=E:workspace.metadata.pluginsorg.eclipse.wst.server.core	mp0wtpwebapps
    六月 28, 2017 9:02:25 上午 org.apache.catalina.startup.VersionLoggerListener log
    信息: Command line argument: -Djava.endorsed.dirs=D:wulinfeng	omcatapache-tomcat-8.5.13endorsed
    六月 28, 2017 9:02:25 上午 org.apache.catalina.startup.VersionLoggerListener log
    信息: Command line argument: -Dfile.encoding=UTF-8
    六月 28, 2017 9:02:25 上午 org.apache.catalina.core.AprLifecycleListener lifecycleEvent
    信息: Loaded APR based Apache Tomcat Native library 1.2.12 using APR version 1.5.2.
    六月 28, 2017 9:02:25 上午 org.apache.catalina.core.AprLifecycleListener lifecycleEvent
    信息: APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true].
    六月 28, 2017 9:02:25 上午 org.apache.catalina.core.AprLifecycleListener lifecycleEvent
    信息: APR/OpenSSL configuration: useAprConnector [false], useOpenSSL [true]
    六月 28, 2017 9:02:26 上午 org.apache.catalina.core.AprLifecycleListener initializeSSL
    信息: OpenSSL successfully initialized (OpenSSL 1.0.2k  26 Jan 2017)
    六月 28, 2017 9:02:26 上午 org.apache.coyote.AbstractProtocol init
    信息: Initializing ProtocolHandler ["http-nio-9090"]
    六月 28, 2017 9:02:27 上午 org.apache.tomcat.util.net.NioSelectorPool getSharedSelector
    信息: Using a shared selector for servlet write/read
    六月 28, 2017 9:02:27 上午 org.apache.coyote.AbstractProtocol init
    信息: Initializing ProtocolHandler ["ajp-nio-8009"]
    六月 28, 2017 9:02:27 上午 org.apache.tomcat.util.net.NioSelectorPool getSharedSelector
    信息: Using a shared selector for servlet write/read
    六月 28, 2017 9:02:27 上午 org.apache.catalina.startup.Catalina load
    信息: Initialization processed in 2954 ms
    六月 28, 2017 9:02:27 上午 org.apache.catalina.core.StandardService startInternal
    信息: Starting service Catalina
    六月 28, 2017 9:02:27 上午 org.apache.catalina.core.StandardEngine startInternal
    信息: Starting Servlet Engine: Apache Tomcat/8.5.13
    六月 28, 2017 9:02:34 上午 org.apache.jasper.servlet.TldScanner scanJars
    信息: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
    六月 28, 2017 9:02:34 上午 org.apache.catalina.core.ApplicationContext log
    信息: No Spring WebApplicationInitializer types detected on classpath
    六月 28, 2017 9:02:36 上午 org.apache.catalina.core.ApplicationContext log
    信息: Initializing Spring root WebApplicationContext
    六月 28, 2017 9:02:38 上午 org.apache.catalina.core.StandardContext listenerStart
    严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
    org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Failed to import bean definitions from relative location [microservice.xml]
    Offending resource: class path resource [spring-core.xml]; nested exception is org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Bean name 'ms.selection.abetOrOpposePostService' is already used in this <beans> element
    Offending resource: class path resource [microservice.xml]
    
        at org.springframework.beans.factory.parsing.FailFastProblemReporter.error(FailFastProblemReporter.java:70)
        at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:85)
        at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:76)
        at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.importBeanDefinitionResource(DefaultBeanDefinitionDocumentReader.java:255)
        at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseDefaultElement(DefaultBeanDefinitionDocumentReader.java:180)
        at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:165)
        at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.doRegisterBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:138)
        at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.registerBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:94)
        at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:508)
        at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:392)
        at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:336)
        at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:304)
        at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:181)
        at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:217)
        at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:188)
        at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:125)
        at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:94)
        at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:129)
        at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:612)
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:513)
        at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:444)
        at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:326)
        at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:107)
        at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4745)
        at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5207)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
        at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1419)
        at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1409)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at java.lang.Thread.run(Thread.java:748)
    Caused by: org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Bean name 'ms.selection.abetOrOpposePostService' is already used in this <beans> element
    Offending resource: class path resource [microservice.xml]
    
        at org.springframework.beans.factory.parsing.FailFastProblemReporter.error(FailFastProblemReporter.java:70)
        at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:85)
        at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:80)
        at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.error(BeanDefinitionParserDelegate.java:301)
        at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.checkNameUniqueness(BeanDefinitionParserDelegate.java:511)
        at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseBeanDefinitionElement(BeanDefinitionParserDelegate.java:457)
        at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseBeanDefinitionElement(BeanDefinitionParserDelegate.java:429)
        at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.processBeanDefinition(DefaultBeanDefinitionDocumentReader.java:295)
        at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseDefaultElement(DefaultBeanDefinitionDocumentReader.java:186)
        at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:165)
        at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.doRegisterBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:138)
        at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.registerBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:94)
        at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:508)
        at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:392)
        at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:336)
        at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:304)
        at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.importBeanDefinitionResource(DefaultBeanDefinitionDocumentReader.java:239)
        ... 28 more
    
    六月 28, 2017 9:02:38 上午 org.apache.catalina.core.StandardContext startInternal
    严重: One or more listeners failed to start. Full details will be found in the appropriate container log file
    六月 28, 2017 9:02:38 上午 org.apache.catalina.core.StandardContext startInternal
    严重: Context [/ms-selection] startup failed due to previous errors
    六月 28, 2017 9:02:38 上午 org.apache.catalina.core.ApplicationContext log
    信息: Closing Spring root WebApplicationContext
    六月 28, 2017 9:02:38 上午 org.apache.catalina.core.StandardContext listenerStop
    严重: Exception sending context destroyed event to listener instance of class org.springframework.web.context.ContextLoaderListener
    java.lang.IllegalStateException: BeanFactory not initialized or already closed - call 'refresh' before accessing beans via the ApplicationContext
        at org.springframework.context.support.AbstractRefreshableApplicationContext.getBeanFactory(AbstractRefreshableApplicationContext.java:170)
        at org.springframework.context.support.AbstractApplicationContext.destroyBeans(AbstractApplicationContext.java:1010)
        at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:986)
        at org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:938)
        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:4792)
        at org.apache.catalina.core.StandardContext.stopInternal(StandardContext.java:5429)
        at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:226)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)
        at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1419)
        at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1409)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at java.lang.Thread.run(Thread.java:748)
    
    六月 28, 2017 9:02:38 上午 org.apache.coyote.AbstractProtocol start
    信息: Starting ProtocolHandler ["http-nio-9090"]
    六月 28, 2017 9:02:38 上午 org.apache.coyote.AbstractProtocol start
    信息: Starting ProtocolHandler ["ajp-nio-8009"]
    六月 28, 2017 9:02:38 上午 org.apache.catalina.startup.Catalina start
    信息: Server startup in 11670 ms

      从报错信息看是说该bean已经被用过,有点让人摸不着头脑,仔细检查了bean加载文件后才发现,在spring-core.xml里加载microservice.xml,而microservice.xml里配置了两个一样名叫ms.selection.abetOrOpposePostService的bean。解决方法是删掉重复bean中的一个,保证bean的ID的唯一性。

  • 相关阅读:
    C# 按笔画排序
    WEB EXCEL OWC开发(老资料)
    JS操作Cookie
    汉字转拼音缩写取首字母
    javaScript通用数据类型校验
    嵌套Repeater 子层获得父层字段值 经典!!!
    不同于其他的provider: SQL 网络接口, error: 26 定位指定的服务器/实例时出错
    C# UDP 发送 接收
    Js 过滤空格
    高亮文本框
  • 原文地址:https://www.cnblogs.com/wuxun1997/p/7088196.html
Copyright © 2020-2023  润新知