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


            今天配置完:

           

<!-- 自动扫描与装配,包含子包 -->
	<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中各种版本,如果没有的话,会自动使用最新版本。







评论 10
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

水田如雅

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值