我在编程过程中是有ApplicationContext.xml的文件,但是在tomcat中加载的时候总是出现找不到这个文件错误

但是出现: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListenerorg.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [applicationContext.xml]; nested exception is java.io.FileNotFoundException: class path resource [applicationContext.xml] cannot be opened because it does not exist
的错误,求高手帮忙看看肿么回事???谢谢

web.xml里边没有配置<context>标签及监听器,
servelt初始化方法init()里边也要加上context初始化的代码
web.xml里边加上
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/classes/applicationContext.xml</param-value>
</context-param>
Servlet的初始化方法init()里加上

ServletContext servletContext = this.getServletContext();
applicationContext = WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext);
别忘引入相应的jar包追问

我是这样配置的,请问哪里需要添加丫,怎么添的呢?谢谢大神。。。

追答

里的路径改为相对路径试试,
/WEB-INF/applicationContext.xml
看你错误应该是这个路径不对,具体路径你去tomcat的webapps下找相应的工程,看你自己把这个xml放哪了,如果在src包就用/WEB-INF/classes/applicationContext.xml

追问

您好,放在相对路径下面的话它找是找到这个文件了,但是出现了这样的问题:

请问是什么原因丫?看不明白,谢谢啊

追答

你的applicationContext.xml到底放在哪个位置,把工程package截图贴出来

温馨提示:答案为网友推荐,仅供参考

相关了解……

你可能感兴趣的内容

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 非常风气网