【问题标题】:'context:component-scan' not working“上下文:组件扫描”不起作用
【发布时间】:2014-09-02 18:59:48
【问题描述】:

在运行应用程序时,它在 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>

【问题讨论】:

标签: java xml spring


【解决方案1】:

当我像下面这样更改 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"; 

(带有各自的架构)

【讨论】:

    猜你喜欢
    • 2015-12-12
    • 2012-09-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-05-25
    • 1970-01-01
    • 2016-10-21
    相关资源
    最近更新 更多