- <context-param>
- <param-name>contextconfiglocation</param-name>
- < param-v Alue >classpath: Applicationcontext.xml</param-value>
- </context-param>
Note that this configuration is written as far as possible, because the Web project initializes the context after Tomcat is started, which is exactly the file location where the context configuration is specified, and the rest of the configuration should continue to load after the context initialization is complete. And our Springmvc servlet is just a configuration of the SPRINGMVC framework, just like the configuration of struts2, and the whole project is managed by spring.
Learn from: http://blog.csdn.net/wlwlwlwl015/article/details/48134763
Error message:
Month 10, 2017 9:31:12 pm Org.apache.catalina.core.ApplicationContext log Info: Initializing Spring root Webapplicationcontext II Month 10, 2017 9:31:13 pm org.apache.catalina.core.StandardContext listenerstart severity: Exception Sending contextinitializedEvent to listener instance of class Org.springframework.web.context.ContextLoaderListener Org.springframework.beans.factory.BeanDefinitionStoreException:IOException parsing XML document from ServletContext resource [/web-inf/applicationcontext.xml];nested exception is java.io.FileNotFoundException:Could not open ServletContext resource [/web-inf/applicationcontext.xml] At Org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions ( xmlbeandefinitionreader.java:344) 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:537) at Org.springframework.context.support.AbstractApplicationContext.refresh (abstractapplicationcontext.java:452) at Org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext ( contextloader.java:403) at Org.springframework.web.context.ContextLoader.initWebApplicationContext ( contextloader.java:306) at org.springframework.web.context.ContextLoaderListener.contextInitialized ( contextloaderlistener.java:106) at Org.apache.catalina.core.StandardContext.listenerStart ( standardcontext.java:4812) at org.apache.catalina.core.StandardContext.startInternal (Standardcontext.java : 5255) at Org.apache.catalina.util.LifecycleBase.start (lifecyclebase.java:147) at Org.apache.catalina.core.containerbase$startchild.call (containerbase.java:1408) at Org.apache.catalina.core.containerbase$startchild.call (containerbase.java:1398) 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:745) caused by:java.io.FileNotFoundException:Could not open ServletContext resource [/web-inf/ Applicationcontext.xml] at Org.springframework.web.context.support.ServletContextResource.getInputStream ( servletcontextresource.java:141) at Org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions (Xmlbeandefinitionreader.java : More
February 10, 2017 9:31:13 pm Org.apache.catalina.core.StandardContext startinternal Serious: One or more listeners failed to start. Full details would be found in the appropriate container log file February 10, 2017 9:31:13 pm ORG.APACHE.CATALINA.UTIL.SESSIONID Generatorbase createsecurerandom Info: Creation of SecureRandom instance for session ID generation using [Sha1prng] took [17 9] milliseconds. February 10, 2017 9:31:13 pm org.apache.catalina.core.StandardContext startinternal severity: Context [/springunit01] startup failed D UE to previous Errors February 10, 2017 9:31:13 pm Org.apache.catalina.core.ApplicationContext log Info: Closing Spring root WEBAP Plicationcontext February 10, 2017 9:31:13 pm Org.apache.catalina.core.StandardContext listenerstop serious: Exception sending Conte XT 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 &nbsP;at Org.springframework.context.support.AbstractRefreshableApplicationContext.getBeanFactory ( abstractrefreshableapplicationcontext.java:170) at Org.springframework.context.support.AbstractApplicationContext.destroyBeans (Abstractapplicationcontext.java : 908) at Org.springframework.context.support.AbstractApplicationContext.doClose ( abstractapplicationcontext.java:884) at Org.springframework.context.support.AbstractApplicationContext.close (abstractapplicationcontext.java:836) at Org.springframework.web.context.ContextLoader.closeWebApplicationContext (contextloader.java:579) At org.springframework.web.context.ContextLoaderListener.contextDestroyed (contextloaderlistener.java:115) At Org.apache.catalina.core.StandardContext.listenerStop (standardcontext.java:4859) at Org.apache.catalina.core.StandardContext.stopInternal (standardcontext.java:5478) at Org.apache.catalina.util.LifecycleBase.stop (lifecyclebase.java:224)
Nested exception is java.io.FileNotFoundException:Could not open ServletContext resource