system Environment: jdk8+eclipse4.4+tomcat7.x+spring4.1.3+hibernate4.3.7+struts2.3.20, my configuration files are stored in the SRC directory. First, the spring default profile is Applicationcontext.xml, and if you do not call this name, you need to specify it, by adding it in the Web. xml file:<param-name>contextConfigLocation</param-name> and <param-value>classpath:beans.xml, Classpath:action-beans.xml</param-value> Unfortunately, Tomcat starts off with an error similar to the following:
< Span style= "Background-color:inherit" > org.springframework.beans.factory.beandefin Itionstoreexception:ioexception parsing XML document from ServletContext resource [/web-inf/beans.xml]; Nested exception is java.io.FileNotFoundException:Could not open ServletContext resource [/web-inf/beans.xml] & nbsp; caused by:java.io.FileNotFoundException:Could not open ServletContext resource [/ web-inf/beans.xml] |
Finally, after constant testing and adjustment, the following conclusions are obtained, for reference only:
| <!--needed for Contextloaderlistener --<!--Specify the location of the spring configuration file--<context-param><param-name>contextConfigLocation</param-name><!--can successfully load the configuration file --<!--<param-value>/WEB-INF/classes/beans.xml,/WEB-INF/classes/action-beans.xml</param-value> -<!--The configuration file cannot be loaded successfully --<!--<param-value>/WEB-INF/beans.xml,/WEB-INF/action-beans.xml</param-value> --<!--can successfully load the configuration file --<!--<param-value>classpath:*beans.xml</param-value> --<!--The configuration file cannot be loaded successfully --<!--<param-value>classpath:beans.xml,action-beans.xml</param-value> --<!--can successfully load the configuration file --<param-value>classpath:beans.xml,classpath:action-beans.xml</param-value></context-param><!--bootstraps the root Web application context before servlet initialization --<listener><listener-class>org.springframework.web.context.ContextLoaderListener</listener-class></listener> |
In fact, I do not know much, but I believe StackOverflow, I believe that foreigners ah, see here is a word, so to speakHttp://stackoverflow.com/questions/6035464/could-not-open-servletcontext-resource
Do not use Classpath. This could cause problems with different classloaders (container vs. application). Web-inf is always the better choice.
|
do not use classpath, it is recommended to use Web-inf when the loader of the class may be different. the best configuration is to create a new source folder in the same directory as the SRC, then include all the configuration files, and then in Web. XML, use the web-inf/classes/ Beans.xml is configured, and multiple files are separated by commas.
finally:
SSH Integrated Org.springframework.beans.factory.BeanDefinitionStoreException:IOException