Symptom
An error occurred while running the application task.
{code}Caused by: java.lang.IllegalStateException: Duplicate spring bean id realnameAuthPubService at com.alibaba.dubbo.rpc.config.spring.schema.DubboBeanDefinitionParser.parse(DubboBeanDefinitionParser.java:87) at com.alibaba.dubbo.rpc.config.spring.schema.DubboBeanDefinitionParser.parse(DubboBeanDefinitionParser.java:63) at org.springframework.beans.factory.xml.NamespaceHandlerSupport.parse(NamespaceHandlerSupport.java:69) at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1297) at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1287) at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:135) at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.registerBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:92) at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:507) at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:398){code}Troubleshooting
Check the Code. There is indeed a duplicate configuration with the ID realnameauthpubservice, but it has been around for a long time and has never been a problem before.
The problem occurred only when the Dubbo upgrade requirement was released on the day. Therefore, it was found that the Dubbo upgrade caused this persistent problem.
The cause of spring's default processing policy for ID duplication is overwriting, such as defaultlistablebeanfactory. registerbeandefinition. Dubbo did not perform special processing before, so duplicate IDs will be overwritten, so no error is reported.
{Code}... synchronized (this. beandefinitionmap) {object oldbeandefinition = This. beandefinitionmap. Get (beanname); If (oldbeandefinition! = NULL) {## allowbeandefinitionoverriding default value: tureif (! This. allowbeandefinitionoverriding) {Throw new beandefinitionstoreexception (beandefinition. getresourcedescription (), beanname, "cannot register bean Definition [" + beandefinition + "] for bean '" + beanname + "': there is already [" + oldbeandefinition + "] bound. ");} else {If (this. logger. isinfoenabled () {this.logger.info ("overriding bean definition for bean '" + beanname + "': replacing ["+ oldbeandefinition +"] with ["+ beandefinition +"] ") ;}} else {This. beandefinitionnames. add (beanname); this. frozenbeandefinitionnames = NULL ;}## overwrite this. beandefinitionmap. put (beanname, beandefinition );... {code}The new version of Dubbo performs special processing on duplicate IDs. If there are duplicates, an exception is thrown directly, so an error occurs.
{Code} dubbobeandefinitionparser. parse private beandefinition parse (element, parsercontext, class <?> Beanclass, Boolean required) {... If (ID! = NULL & ID. length ()> 0) {### determine whether the existence exists. If (parsercontext. getregistry (). containsbeandefinition (ID) {Throw new illegalstateexception ("Duplicate spring bean ID" + id);} parsercontext. getregistry (). registerbeandefinition (ID, beandefinition );}...} {code}