Spring:通配符的匹配很全面, 但无法找到元素 XXXXX' 的声明
问题:配置Spring的时候容易发生如题的这样一个经常性的错误,错误如下(以context为例)
org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException:
Line 8 in XML document from class path resource [applicationContext.xml] is invalid;
nested exception is org.xml.sax.SAXParseException;
lineNumber: 8; columnNumber: 47; cvc-complex-type.2.4.c:
通配符的匹配很全面, 但无法找到元素 'context:component-scan' 的声明。
再看看beans的约束:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
>
咦?这不是有context的声明吗,
没错,不过还少了一些东西,那就是关于context的xsi的模式地址 xsi:schemaLocation 的更新
xmlns:全名是xml namespace,也即是为当前的这个xml指定命名空间。
xmlns:xsi:是指当前xml所要遵循的标签规范.
如上xmlns配上hdp, xsi, aop, cache, context, mvc…都是当前xml要使用到的一个标签,后面就是指定标签所要遵循的规范。
xsi:schemaLocation:指定的命名空间对应的验证文件,用来定义xml schema的地址,也就是xml书写时需要遵循的语法,用于声明了目标命名空间的模式文档。。两部分组成,前面部分就是命名空间的名字,后面是xsd(xmlschema)文档的地址,也是就表示把定义这个命名空间的schema文件给引用进来,好让eclipse这类型工具能够解析和验证你的xml文件是否符合语法规范。简单来说就是声明了目标命名空间的模式文档。
解决方案:除了要添加xmlns:XXX之外,还需要添加对应的xsi:schemaLocation【可以去google一下所需要的xsi:schemaLocation】
如下:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd"
>
Spring:通配符的匹配很全面, 但无法找到元素 XXXXX' 的声明的更多相关文章
- 关于spring”通配符的匹配很全面, 但无法找到元素 'context:component-scan' 的声明“的错误
关于spring配置的问题 近日学习spring时遇到了这个问题: org.springframework.beans.factory.xml.XmlBeanDefinitionStoreExcept ...
- nested exception is org.xml.sax.SAXParseException; lineNumber: 8; columnNumber: 56; cvc-complex-type.2.4.c通配符的匹配很全面, 但无法找到元素 'dubbo:application' 的声明
严重: Exception sending context initialized event to listener instance of class org.springframework.we ...
- 通配符的匹配很全面, 但无法找到元素 'cache:advice' 的声明
EB-INF\classes\spring-jdbc.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineN ...
- idea调试SpringMvc, 出现:”通配符的匹配很全面, 但无法找到元素 'mvc:annotation-driven' 的声明“错误的解决方法
调试json格式输出,出现以下错误: HTTP Status 500 - Servlet.init() for servlet HelloDispatcher threw exception ty ...
- dubbo 常见错误 通配符的匹配很全面, 但无法找到元素 'dubbo:application' java.lang.reflect.MalformedParameterizedTypeException 通配符的匹配很全面, 但无法找到元素 'dubbo:application' 的声明。 Unsupported major.minor version 52.0 (unable to l
dubbo 常见错误 1. Caused by: java.lang.reflect.MalformedParameterizedTypeException 启动时报错,原因是dubbo 依赖 spr ...
- springMVC:通配符的匹配很全面, 但无法找到元素 'mvc:annotation-driven' 的声明
转自:http://blog.csdn.net/tolcf/article/details/50845483 报错信息:通配符的匹配很全面, 但无法找到元素 'mvc:annotation-drive ...
- 通配符的匹配很全面, 但无法找到元素 'mvc:annotation-driven' 的声明
通配符的匹配很全面, 但无法找到元素 'mvc:annotation-driven' 的声明 错误原因是springmvc中的约束信息不对 <beans xmlns="http://w ...
- 通配符的匹配很全面, 但无法找到元素 'tx:annotation-driven' 的声明
启动Tomcat时报错,通配符的匹配很全面, 但无法找到元素 'tx:annotation-driven' 的声明,报错如下 1.从报错可以看到找不到元素 tx:annotation-driven ...
- Spring常见问题-通配符的匹配很全面, 但无法找到元素 'aop:aspectj-autoproxy' 的声明
随机推荐
- Python2在Sublime Text3中print中文时编译报错解决办法
如果是用记事本新建的python文件,有可能是由于记事本默认的ascii格式导致的,这个时候只需要在Sublime Text3中 文件->设置文件编码(utf-8),保存即可.这样能够解决的 ...
- 单源最短距离 Single Source Shortest Path
单源最短距离_示例程序_图模型_用户指南_MaxCompute-阿里云 https://help.aliyun.com/document_detail/27907.html 单源最短距离 更新时间:2 ...
- FW qunit introduction
自动化测试软件对于开发来说是一个很重要的工具,而单元测试对于自动化测试来说是基本组成部分:软件的每一个组件或者单元可以在非人工介入的情况下,使用测试工具一遍遍的重复执行.换句话说,就是你可以写一次测试 ...
- XML 之快速入门
XML 简介 - XML, 即可扩展标记语言(eXtensible Markup Language), 是一种标记语言. - 标记型语言: 使用标签进行操作 - 可扩展: XML 的标签可以自定义 - ...
- 我的Android进阶之旅------>Android关于HttpsURLConnection一个忽略Https证书是否正确的Https请求工具类
下面是一个Android HttpsURLConnection忽略Https证书是否正确的Https请求工具类,不需要验证服务器端证书是否正确,也不需要验证服务器证书中的域名是否有效. (PS:建议下 ...
- 前端基础-css(1)
一.css的引入方式 现在的互联网前端分三层: HTML:超文本标记语言.从语义的角度描述页面结构. CSS:层叠样式表.从审美的角度负责页面样式. JS:JavaScript .从交互的角度描述页面 ...
- 查看Oracle的表中有哪些索引
用user_indexes和user_ind_columns系统表查看已经存在的索引 对于系统中已经存在的索引我们可以通过以下的两个系统视图(user_indexes和user_ind_columns ...
- Hadoop MapReduce InputFormat基础
有时候你可能想要用不同的方法从input data中读取数据.那么你就需要创建一个自己的InputFormat类. InputFormat是一个只有两个函数的接口. public interf ...
- github-----文件项目的推拉二式
将本地项目文件推送上线: $ git init $ git add . $ git commit -m "第一次修改" $ git log $ git remote add ori ...
- Python:笔记(5)——错误、调试和测试
Python:笔记(5)——错误.调试和测试 错误处理 1.TRY语句 这个和Java中的语法是及其相似的,catach换成except. 说明:同样,不管有没有错误,fianlly都会执行的! 补充 ...