spring学习之路2
来源:互联网 发布:java多线程编程实战 编辑:程序博客网 时间:2024/05/24 01:42
接前面的那一章节内容,在想使用spring配置自动扫描包的时候报错了
按照 http://blog.csdn.net/qq_19558705/article/details/50086977
的作者所述及进行操作的时候
<!-- 配置自动扫描的包 --> <context:component-scan base-package="com.spring.common.beans"/>
报错信息:
org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 9 in XML document from class path resource [applicationContext.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 9; columnNumber: 69; 元素 "context:component-scan" 的前缀 "context" 未绑定。at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:399)at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:336)at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:304)at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:181)at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:217)at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:188)at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:252)at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:127)at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:93)。。。at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)Caused by: org.xml.sax.SAXParseException; lineNumber: 9; columnNumber: 69; 元素 "context:component-scan" 的前缀 "context" 未绑定。at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:203)。。。
发现原作者使用的spring3.x的xml命名空间;原:
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:util="http://www.springframework.org/schema/util" xmlns:p="http://www.springframework.org/schema/p" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd" xmlns:context="http://www.springframework.org/schema/context">要更改成:
<?xml version="1.0" encoding="UTF-8"?><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:tx="http://www.springframework.org/schema/tx" xmlns:jdbc="http://www.springframework.org/schema/jdbc"xmlns:task="http://www.springframework.org/schema/task" xmlns:cache="http://www.springframework.org/schema/cache"xmlns:p="http://www.springframework.org/schema/p"xsi:schemaLocation="http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc.xsdhttp://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task.xsdhttp://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsdhttp://www.springframework.org/schema/cache http://www.springframework.org/schema/cache/spring-cache.xsdhttp://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsdhttp://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd"> <!-- 配置自动扫描的包 --> <context:component-scan base-package="com.spring.common.beans"/>然后跑单元测试,发现没问题了。
0 0
- spring学习之路2
- Spring学习之路
- Spring学习之路
- Spring学习之路--开始学spring
- spring学习之路1
- spring-boot 学习之路
- spring 之 springMVC 学习2
- Spring之在学习(2)
- java学习之路----spring探索2---注解
- spring boot 学习之路2(注解介绍)
- spring学习之spring简介
- Spring学习之Spring JDBC
- spring源码学习之路---AOP初探
- spring源码学习之路---IOC初探
- 小白的Spring学习之路
- SPRING源码学习之路(一)
- SPRING源码学习之路(二)
- mybaties+Spring mvc学习之路笔记
- 微信开发config:invalid signature
- onHiddenChanged
- Java 环境变量配置 Windows
- POCO C++库学习和分析 -- 日志 (一)
- 虚拟机安装后TP框架验证码失效
- spring学习之路2
- 作为新手,关于APP启动时出现空白页才跳到启动页,解决办法如下
- JQuery EasyUI常用控件的禁用方法
- JAVA 注解(Annotation)详解
- 安徽大学第九届大学生程序设计竞赛 网络预选赛
- MongoDB 聚合管道(一)(Aggregation Pipeline)
- 可配置路径的excel导出工具类
- 用 Docker 构建、运行、发布一个 Spring Boot 应用
- android studio问题:installation failed with message INSTALL_CANCELED_BY_USER