applicationContext.xml 找不到元素 'beans' 的声明的问题

突然发现我的工程在断网的条件下无法使用,报错:cvc-elt.1: 找不到元素 'beans' 的声明。
上网查找后,仔细核对过。
applicationContext.xml :
<?xml version="1.0" encoding="UTF-8"?>

xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">

 spring-beans-3.2.8.RELEASE.jar 包下的spring.schemas:

 http\://www.springframework.org/schema/beans/spring-beans-2.0.xsd=org/springframework/beans/factory/xml/spring-beans-2.0.xsd
http\://www.springframework.org/schema/beans/spring-beans-2.5.xsd=org/springframework/beans/factory/xml/spring-beans-2.5.xsd
http\://www.springframework.org/schema/beans/spring-beans-3.0.xsd=org/springframework/beans/factory/xml/spring-beans-3.0.xsd
http\://www.springframework.org/schema/beans/spring-beans-3.1.xsd=org/springframework/beans/factory/xml/spring-beans-3.1.xsd
http\://www.springframework.org/schema/beans/spring-beans-3.2.xsd=org/springframework/beans/factory/xml/spring-beans-3.2.xsd
http\://www.springframework.org/schema/beans/spring-beans.xsd=org/springframework/beans/factory/xml/spring-beans-3.2.xsd
http\://www.springframework.org/schema/tool/spring-tool-2.0.xsd=org/springframework/beans/factory/xml/spring-tool-2.0.xsd
http\://www.springframework.org/schema/tool/spring-tool-2.5.xsd=org/springframework/beans/factory/xml/spring-tool-2.5.xsd
http\://www.springframework.org/schema/tool/spring-tool-3.0.xsd=org/springframework/beans/factory/xml/spring-tool-3.0.xsd
http\://www.springframework.org/schema/tool/spring-tool-3.1.xsd=org/springframework/beans/factory/xml/spring-tool-3.1.xsd
http\://www.springframework.org/schema/tool/spring-tool-3.2.xsd=org/springframework/beans/factory/xml/spring-tool-3.2.xsd
http\://www.springframework.org/schema/tool/spring-tool.xsd=org/springframework/beans/factory/xml/spring-tool-3.2.xsd
http\://www.springframework.org/schema/util/spring-util-2.0.xsd=org/springframework/beans/factory/xml/spring-util-2.0.xsd
http\://www.springframework.org/schema/util/spring-util-2.5.xsd=org/springframework/beans/factory/xml/spring-util-2.5.xsd
http\://www.springframework.org/schema/util/spring-util-3.0.xsd=org/springframework/beans/factory/xml/spring-util-3.0.xsd
http\://www.springframework.org/schema/util/spring-util-3.1.xsd=org/springframework/beans/factory/xml/spring-util-3.1.xsd
http\://www.springframework.org/schema/util/spring-util-3.2.xsd=org/springframework/beans/factory/xml/spring-util-3.2.xsd
http\://www.springframework.org/schema/util/spring-util.xsd=org/springframework/beans/factory/xml/spring-util-3.2.xsd

之后我也试着改了applicationContext里的http://www.springframework.org/schema/beans/spring-beans-3.0.xsd为classpath:/org/springframework/beans/factory/xml/spring-beans-3.0.xsd,也不好用。报的错误是一样的。

至于说版本的问题,我用的spring 3.2.8,改成3.2.xsd,或者2.5.xsd都不好用。怀疑是eclipse的问题,然而重新建了一遍工程也一样。求救啊~



建议你使用sts插件,添加命名空间很方便

主题贴

楼主 搜索更多

java吧

40w

SPRING报错提示找不到applicationcontext但是能正常使用

步步高饮水机 1 
1楼2015-2-15

操作

严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.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
提示不存在,但是用 ApplicationContext context= new ClassPathXmlApplicationContext("applicationContext.xml");可以提取到
applicationContext.xml是放在src源文件夹下面的,web.xml里的配置是

org.springframework.web.context.ContextLoaderListener


contextConfigLocation
/WEB-INF/classes/applicationContext.xml

也试过classpath:applicationContext.xml,也不行
另外在jsp中使用了struts标签后,运行时会在后台输出web.xml里的内容

 contextConfigLocation
 /WEB-INF/classes/applicationContext.xml
 
 
 OpenSessionInViewFilter
 org.springframework.orm.hibernate3.support.OpenSessionInViewFilter
 false
 
 
 struts2
 org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
 false
 
 
 OpenSessionInViewFilter
 .action
 
 
 struts2
 /
 
 
 org.springframework.web.context.ContextLoaderListener
 
 
 jsp
 org.apache.jasper.servlet.JspServlet
 
 fork
 false
 
 
 xpoweredBy
 false
 
 3
 
 
 default
 org.apache.catalina.servlets.DefaultServlet
 
 debug
 0
 
 
 listings
 false
 
 1
 
 
 jsp
 .jsp
 
 
 jsp
 .jspx
 
 
 default
 /
 
 
 30
 
 
 
 
 fh7
 image/x-freehand
 
 
 fh5
 image/x-freehand
 
 
 xhvml
 application/xv+xml
 
 
 fh4
 image/x-freehand
 
 
 x3db
 model/x3d+binary
 
还有很多类似这样的内容,因为太长不截取了,现在发现如果不使用struts2标签就不会输出这些,希望高手能告诉我是怎么回事

使用客户端继续浏览

推广 原来手机上是这么踢足球的!触屏按钮射门好带劲儿!

5秒下载

步步高饮水机 1 
2楼2015-2-15

操作

struts.xml的配置

 <!-- 详细信息,开发阶段打开 -->
 
 <!-- 集成spring -->
 


/error.jsp


 
 
 /index.jsp
 /student/addstudent.jsp
 /student/addstudent.jsp
 
 
 
 
 /student/default1.jsp
 /teacher/default2.jsp
 /admin/default3.jsp
 /index.jsp
 /index.jsp
 
  
 <!--  -->
 <!-- Add packages here -->