高分spring 中 ClassPathXmlApplicationContext问题

kcitwm 2005-07-26 06:23:50
我把applicationContex.xml放在WEB-INF下面,用ClassPathXmlApplicationContext (
"/applicationContext-common-business.xml");

ClassPathXmlApplicationContext (
"/WEB-INF/applicationContext-common-business.xml");

ClassPathXmlApplicationContext (
"applicationContext-common-business.xml");

都老是说找不到文件,怎么办.是不是要设置什么
错误如下:


org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [applicationContext-common-business.xml,/applicationContext-portal.xml]; nested exception is java.io.FileNotFoundException: class path resource [applicationContext-common-business.xml,/applicationContext-portal.xml] cannot be opened because it does not exist
java.io.FileNotFoundException: class path resource [applicationContext-common-business.xml,/applicationContext-portal.xml] cannot be opened because it does not exist
at org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java:127)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:144)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:99)
at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:102)
at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:70)
at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:87)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:264)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:80)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:65)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:56)
at com.guanghua.AppContext.<init>(AppContext.java:31)
at com.guanghua.AppContext.getInstance(AppContext.java:25)
...全文
1589 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
hm8328 2005-07-27
  • 打赏
  • 举报
回复
告诉你了,不过我要满分噢..呵呵,虽然有点贪,但是我做过这方面,而且想要分升级....

把你的applicationContext-common-business.xml放到WEB-INF/classes下面
然后在你的web.xml中的<display-name>some your modle info</display-name>后面加上:
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:/applicationContext-common-business.xml</param-value>
</context-param>

就OK了
kcitwm 2005-07-27
  • 打赏
  • 举报
回复
能不能不通过编程获得ApplicationContext而是系统中得到?spring 提供了这种方法吗?
flyxxxxx 2005-07-26
  • 打赏
  • 举报
回复
用ClassPathXmlApplicationContext时你必须将它放到WEB-INF/classes下面,否则你应该用FileSystemXmlApplicationContext
stonecsdn 2005-07-26
  • 打赏
  • 举报
回复
放在web-inf/classes下面

81,092

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧