【发布时间】:2013-05-21 15:22:16
【问题描述】:
我是 spring 新手,我知道这个问题已经被问过很多次了,但我不得不再问一遍。
我猜,我已经做了适当的命名空间声明,但仍然面临错误"The prefix "context" for element "context:component-scan" is not bound." 有一个类似的问题here,但我无法得到答案
这是我的 xml 文档,是不是我的命名空间不正确?
<?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>
【问题讨论】:
-
您缺少
context的命名空间声明。 -
我对这些命名空间有点困惑,你能详细说明一下吗?
-
下面的答案涵盖了大部分内容。