新搞了一個單點登陸的項目,用的cas,要把源碼的cas-webapp改形成適合咱們業務場景的項目,因而新加了一些spring的配置文件。php
可是在項目啓動時報錯了,錯誤日誌以下:java
一月 08, 2016 11:01:34 下午 org.apache.catalina.core.StandardContext filterStart 嚴重: Exception starting filter springSecurityFilterChain org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name 'functionServiceImpl': Bean with name 'functionServiceImpl' has been injected into other beans [platformServiceImpl] 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) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:296) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:293) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:628) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:932) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:479) at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:389) at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:294) at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:112) at org.jasig.cas.web.init.SafeContextLoaderListener.contextInitialized(SafeContextLoaderListener.java:75) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:5003) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5517) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1574) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1564) at java.util.concurrent.FutureTask.run(FutureTask.java:262) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at java.lang.Thread.run(Thread.java:745)
去stackoverflow上面搜,說是spring循環依賴致使的。可是問了組裏一個技術牛,說若是是出現spring循環依賴,在啓動項目的時候是不會報錯的,spring的循環依賴在運行的時候纔會報錯。web
循環依賴也可能出如今maven裏,若是maven配置中出現了循環依賴,編譯的時候就會報錯。spring
那麼,到底是什麼緣由,我如今還不知道。apache
在個人web.xml文件中,引入了兩次spring的applicationContext.xml文件。app
<context-param> <param-name>contextConfigLocation</param-name> <param-value> /WEB-INF/spring-configuration/*.xml /WEB-INF/deployerConfigContext.xml classpath:spring/applicationContext.xml </param-value> </context-param>
當我去掉我本身的spring配置時,項目啓動就不報錯了。webapp
<context-param> <param-name>contextConfigLocation</param-name> <param-value> /WEB-INF/spring-configuration/*.xml /WEB-INF/deployerConfigContext.xml </param-value> </context-param>
那是否是由於加載了兩個applicationContext.xml,就至關於初始化了兩個spring容器,有的單例類只容許存在一個實例,可是卻出現了兩個容器的bean,因此報錯了呢?maven
具體問題待排查。ide
問題緣由查到了:spa
因爲剛開始配置spring的時候加載了2遍applicationContext.xml,其中有一個動態代理切面的配置在兩個配置文件中都存在重複了。詳情見:
http://www.cnphp6.com/archives/22031
其實,仍是由於bean加載重複了。