码迷,mamicode.com
首页 > 编程语言 > 详细

Spring配置问题——元素 "context:component-scan" 的前缀 "context" 未绑定

时间:2016-01-04 18:19:06      阅读:8591      评论:0      收藏:0      [点我收藏+]

标签:


            今天配置完:

           

<!-- 自动扫描与装配,包含子包 -->
	<context:component-scan base-package="cn.itcast.oa"></context:component-scan>

        这句话之后,validating 我的spring配置文件就一直走不下去了。当时以为是myeclipse卡了,之后去掉了所有的validating。


         后来写了个单元测试测试Spring配置的时候,发现报错:


         columnNumber:54; 元素 "context:component-scan" 的前缀 "context" 未绑定。


          看来果然是自动装配与扫描有问题。查了下,貌似是少了context的命名空间的问题:


      <beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tx="http://www.springframework.org/schema/tx"
    xsi:schemaLocation="
            http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
            http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
            http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
             http://www.springframework.org/schema/context  
                http://www.springframework.org/schema/context/spring-context-2.5.xsd

            ">


    加上带红色字体的部分,成功run过去了。


     顺便说下xml中各种版本,如果没有的话,会自动使用最新版本。







Spring配置问题——元素 "context:component-scan" 的前缀 "context" 未绑定

标签:

原文地址:http://blog.csdn.net/lhc1105/article/details/50456881

(0)
(2)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!