起因:新需求本地测试(web容器是jetty)通过后,通过自动化构建部署工具部署到测试环境(web容器是weblogic)测试。启动应用服务时,提示16274 [2020-05-08 18:10:44 ] - [[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)'] - [ip=, ERROR org.springframework.web.context.ContextLoader - Context initialization failed
org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name 'payNoService': Bean with name 'payNoService' has been injected into other beans [onlineSaleServerOnline] in its raw version as part of a circular reference, but has eventually been wrapped. This means that said other beans do not use the final version of the bean. This is often the result of over-eager type matching - consider using 'getBeanNamesOfType' with the 'allowEagerInit' flag turned off, for example.
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:548) ~[spring-beans-3.2.4.RELEASE.jar:3.2.4.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458) ~[spring-beans-3.2.4.RELEASE.jar:3.2.4.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295) ~[spring-beans-3.2.4.RELEASE.jar:3.2.4.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223) ~[spring-beans-3.2.4.RELEASE.jar:3.2.4.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292) ~[spring-beans-3.2.4.RELEASE.jar:3.2.4.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194) ~[spring-beans-3.2.4.RELEASE.jar:3.2.4.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:628) ~[spring-beans-3.2.4.RELEASE.jar:3.2.4.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:932) ~[spring-context-3.2.4.RELEASE.jar:3.2.4.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:479) ~[spring-context-3.2.4.RELEASE.jar:3.2.4.RELEASE]
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:389) ~[spring-web-3.2.4.RELEASE.jar:3.2.4.RELEASE]
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:294) ~[spring-web-3.2.4.RELEASE.jar:3.2.4.RELEASE]
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:112) [spring-web-3.2.4.RELEASE.jar:3.2.4.RELEASE]
at weblogic.servlet.internal.EventsManager$FireContextListenerAction.run(EventsManager.java:481) [weblogic.jar:10.3.6.0]
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321) [com.bea.core.weblogic.security.identity_1.2.0.0.jar:1.2.0.0]
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120) [com.bea.core.weblogic.security.wls_1.0.0.0_6-2-0-0.jar:6.2.0.0]
at weblogic.servlet.internal.EventsManager.notifyContextCreatedEvent(EventsManager.java:181) [weblogic.jar:10.3.6.0]
at weblogic.servlet.internal.WebAppServletContext.preloadResources(WebAppServletContext.java:1871) [BUG26519424_10360171017.jar:10.3.6.0]
at weblogic.servlet.internal.WebAppServletContext.start(WebAppServletContext.java:3173) [BUG26519424_10360171017.jar:10.3.6.0]
at weblogic.servlet.internal.WebAppModule.startContexts(WebAppModule.java:1529) [BUG26519424_10360171017.jar:10.3.6.0]
at weblogic.servlet.internal.WebAppModule.start(WebAppModule.java:488) [BUG26519424_10360171017.jar:10.3.6.0]
at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:425) [weblogic.jar:10.3.6.0]
at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:52) [weblogic.jar:10.3.6.0]
at weblogic.application.internal.flow.ModuleStateDriver.start(ModuleStateDriver.java:119) [weblogic.jar:10.3.6.0]
at weblogic.application.internal.flow.ScopedModuleDriver.start(ScopedModuleDriver.java:200) [weblogic.jar:10.3.6.0]
at weblogic.application.internal.flow.ModuleListenerInvoker.start(ModuleListenerInvoker.java:247) [weblogic.jar:10.3.6.0]
at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:425) [weblogic.jar:10.3.6.0]
at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:52) [weblogic.jar:10.3.6.0]
at weblogic.application.internal.flow.ModuleStateDriver.start(ModuleStateDriver.java:119) [weblogic.jar:10.3.6.0]
at weblogic.application.internal.flow.StartModulesFlow.activate(StartModulesFlow.java:27) [weblogic.jar:10.3.6.0]
at weblogic.application.internal.BaseDeployment$2.next(BaseDeployment.java:671) [weblogic.jar:10.3.6.0]
at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:52) [weblogic.jar:10.3.6.0]
at weblogic.application.internal.BaseDeployment.activate(BaseDeployment.java:212) [weblogic.jar:10.3.6.0]
at weblogic.application.internal.SingleModuleDeployment.activate(SingleModuleDeployment.java:44) [weblogic.jar:10.3.6.0]
at weblogic.application.internal.DeploymentStateChecker.activate(DeploymentStateChecker.java:161) [weblogic.jar:10.3.6.0]
at weblogic.deploy.internal.targetserver.AppContainerInvoker.activate(AppContainerInvoker.java:80) [BUG26519424_10360171017.jar:10.3.6.0]
at weblogic.deploy.internal.targetserver.BasicDeployment.activate(BasicDeployment.java:187) [BUG26519424_10360171017.jar:10.3.6.0]
at weblogic.deploy.internal.targetserver.BasicDeployment.activateFromServerLifecycle(BasicDeployment.java:379) [BUG26519424_10360171017.jar:10.3.6.0]
at weblogic.management.deploy.internal.DeploymentAdapter$1.doActivate(DeploymentAdapter.java:51) [weblogic.jar:10.3.6.0]
at weblogic.management.deploy.internal.DeploymentAdapter.activate(DeploymentAdapter.java:200) [weblogic.jar:10.3.6.0]
at weblogic.management.deploy.internal.AppTransition$2.transitionApp(AppTransition.java:30) [weblogic.jar:10.3.6.0]
at weblogic.management.deploy.internal.ConfiguredDeployments.transitionApps(ConfiguredDeployments.java:240) [weblogic.jar:10.3.6.0]
at weblogic.management.deploy.internal.ConfiguredDeployments.activate(ConfiguredDeployments.java:169) [weblogic.jar:10.3.6.0]
at weblogic.management.deploy.internal.ConfiguredDeployments.deploy(ConfiguredDeployments.java:123) [weblogic.jar:10.3.6.0]
at weblogic.management.deploy.internal.DeploymentServerService.resume(DeploymentServerService.java:180) [weblogic.jar:10.3.6.0]
at weblogic.management.deploy.internal.DeploymentServerService.start(DeploymentServerService.java:96) [weblogic.jar:10.3.6.0]
at weblogic.t3.srvr.SubsystemRequest.run(SubsystemRequest.java:64) [weblogic.jar:10.3.6.0]
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:263) [BUG26519424_10360171017.jar:1.11.0.0]
at weblogic.work.ExecuteThread.run(ExecuteThread.java:221) [BUG26519424_10360171017.jar:1.11.0.0]
问题原因:Spring循环依赖
payNoService依赖paymentSupport,paymentSupport依赖onlineSaleServerOnline
onlineSaleServerOnline依赖payNoService
解决办法:删掉paymentSupport(多余的实现),使paymentSupport不依赖onlineSaleServerOnline,这样就不存在payNoService和onlineSaleServerOnline循环依赖了。
验证:代码提交后重新构建部署,应用启动成功,耶!
感想:开发中应避免循环依赖以减少不必要的问题。
所见即所得,有问题要先解决问题,不要想着代码没变化就没问题,不然会错过解决问题的黄金时间。