'context:component-scan'无效

时间:2014-09-02 18:59:48

标签: java xml spring

在运行应用程序时,它在XML中抛出以下错误

The matching wildcard is strict, but no declaration can be found for element 'context:component-scan'.

但我也添加了xmlns:context和架构。我也尝试过使用Spring 4.0。 有人可以帮忙吗?

请参阅下面的完整代码

<?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:jee="http://www.springframework.org/schema/jee" xmlns:lang="http://www.springframework.org/schema/lang"
    xmlns:p="http://www.springframework.org/schema/p" xmlns:tx="http://www.springframework.org/schema/tx"
    xmlns:util="http://www.springframework.org/schema/util"

    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
      http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd
      http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.2.xsd
      http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-3.2.xsd
      http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.2.xsd
      http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.2.xsd">
    <context:component-scan base-package="mypack" />

</beans>

1 个答案:

答案 0 :(得分:3)

当我更改xml文件时它起作用如下:

<beans xmlns="springframework.org/schema/beans";
    xmlns:xsi="w3.org/2001/XMLSchema-instance";
    xmlns:aop="springframework.org/schema/aop";
    xmlns:context="springframework.org/schema/context";
    xmlns:flow="springframework.org/schema/webflow-config";
    xmlns:lang="springframework.org/schema/lang";
    xmlns:p="springframework.org/schema/p";
    xmlns:util="springframework.org/schema/util"; 

(使用各自的架构)