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' 的声明
随机推荐
- python框架Scrapy中crawlSpider的使用
一.创建Scrapy工程 #scrapy startproject 工程名 scrapy startproject demo3 二.进入工程目录,根据爬虫模板生成爬虫文件 #scrapy genspi ...
- PLSQL Developer在未安装Oracle Client情况下连接Oracle
常用的Oracle开发的工具有SQL Developer和PL/SQL Developer, 用PL/SQL连接oracle数据库,不管是本地的还是远程的,一般都需要安装oracle客户端 如何达到不 ...
- centos7 docker镜像加速器配置
CentOS的配置方式略微复杂,需要先将默认的配置文件复制出来 /lib/systemd/system/docker.service -> /etc/systemd/system/docker. ...
- PyMongo和MongoEngine
参见 http://stackoverflow.com/questions/5712857/pymongo-vs-mongoengine-for-django https://api.mongodb. ...
- 自定义ActionBar图标
<style name="Theme.glTheme" parent="android:Theme.Holo"> <item name=&qu ...
- 系列文章(二):从WLAN的安全威胁,解析电信诈骗的技术症结——By Me
导读:互联网的无线接入已经成为大趋势,其中无线局域网(又称为WLAN,Wireless Local AreaNetwork)以其使用方便.组网灵活.可扩展性好.成本低等优点,成为互联网特别是移动互联网 ...
- 收藏:几种开源许可证的区别!——By 阮一峰制作
乌克兰程序员Paul Bagwell,画了一张分析图,下面是阮一峰制作的中文版,非常棒,绝对的好东西,收藏这张图供日后查看:
- python 多进程使用Queue通信的例子
import time from multiprocessing import Process,Queue MSG_QUEUE = Queue(5) def startA(msgQueue): whi ...
- 【工具】PC端调试手机端 Html 页面的工具
一.概述 有一个项目需要在手机端显示一个 web 页面,而每次把应用 launch 后,从手机端看比较麻烦,因此搜罗了几种在 PC 端调试手机端页面的工具. 二.工具 http://fonkie.it ...
- mapreduce 运行-指定各种运行参数
mapreduce指定参数 mapreduce在运行的时候可以指定各种参数,这样可以根据实际的应用场景做一下相关的调整 1.指定运行时cpu的个数 hadoop jar hadoop-core-0.1 ...