上下文:组分扫描"不受约束 [英] context:component-scan" is not bound

查看:115
本文介绍了上下文:组分扫描"不受约束的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是春天的新手,我知道这个问题已被多次询问,但我不得不再问一次。

Am new to spring and I know this question has been asked many times, but I had to ask it again.

我想,我已经做了适当的命名空间声明,但仍面临错误元素context:component-scan的前缀context未绑定。有一个类似的问题这里,但我得到答案

I guess,I have done appropriate namespace declarations, but still facing the error "The prefix "context" for element "context:component-scan" is not bound." There is a similar question here, but I dint get the answer

这是我的xml文档,是不是我的命名空间不正确?

Here is my xml document, Is it that my namespace is not correct ?

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
    http://www.springframework.org/schema/context/spring-context-3.0.xsd">



    <bean id="point1" class="org.sri.proj.Point">
        <property name="x" value="0" />
        <property name="y" value="0" />
    </bean>

    <bean id="point2" class="org.sri.proj.Point">
        <property name="x" value="10" />
        <property name="y" value="10" />
    </bean>

    <context:component-scan base-package="org.sri.proj"/>

</beans>


推荐答案

添加上下文应用程序上下文文件中 beans 标记定义的名称空间声明

Add the context namespace declaration to the beans tag definition in the application context file

<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"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
    http://www.springframework.org/schema/context
    http://www.springframework.org/schema/context/spring-context-3.0.xsd">  

这篇关于上下文:组分扫描&QUOT;不受约束的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆