我是春天的新手,我知道这个问题已被多次询问,但我不得不再问一次.
我想,我已经做了适当的命名空间声明,但依然面临着错误 "The prefix "context" for element "context:component-scan" is not bound." 有一个类似的问题在这里,但我不力得到答案
这是我的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>
Run Code Online (Sandbox Code Playgroud)
Rei*_*eus 82
将context名称空间声明添加到beans应用程序上下文文件中的标记定义
<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">
Run Code Online (Sandbox Code Playgroud)
是的,你必须添加
http://www.springframework.org/schema/context
Run Code Online (Sandbox Code Playgroud)
之前
http://www.springframework.org/schema/context/spring-context-3.0.xsd
Run Code Online (Sandbox Code Playgroud)
所以它看起来像:
<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">
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
48944 次 |
| 最近记录: |