Spring WS教程:没有找到元素'context:component-scan'错误的声明

时间:2011-07-20 23:45:22

标签: web-services spring-ws sts-springsourcetoolsuite servlets

我正在逐步(基本上复制和粘贴内容)这个spring-ws教程,我在配置 spring-ws-servlet.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"
   xmlns:context="http://www.springframework.org/schema/context"
   xmlns:sws="http://www.springframework.org/schema/web-services"
   xsi:schemaLocation="http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
    http://www.springframework.org/schema/web-services
    http://www.springframework.org/schema/web-services/web-services-2.0.xsd">

    <context:component-scan base-package="com.mycompany.hr"/>

    <sws:annotation-driven/>

</beans>

添加以下行:

<context:component-scan base-package="com.mycompany.hr"/>
让STS开始对我大喊:

cvc-complex-type.2.4.c: The matching wildcard is strict,
but no declarationcan be found for element 'context:component-scan'.

我不知道如何继续......

1 个答案:

答案 0 :(得分:1)

您需要添加:      http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd

到schemaLocation。