zoukankan      html  css  js  c++  java
  • 通配符的匹配很全面, 但无法找到元素 'context:component-scan' 的声明

    一开始的context.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"
           xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
        <context:component-scan base-package="com.alice.*"/>
        <context:property-placeholder location="classpath:config.properties"/>
        <import resource="classpath*:application-cache.xml" />
        <import resource="classpath*:application-spring.xml" />
        <import resource="classpath*:application-mybatis.xml"/>
    </beans>

    结果运行的时候报以下的错误

    通配符的匹配很全面, 但无法找到元素 'context:component-scan' 的声明

    经各种百度,错误原因在于beans中的元素不全面,至少缺少以下两个

    http://www.springframework.org/schema/context  http://www.springframework.org/schema/context/spring-context.xsd
    

    补充完整后,运行即可。

    <?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"
           xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
            http://www.springframework.org/schema/context  http://www.springframework.org/schema/context/spring-context.xsd">
        <context:component-scan base-package="com.alice.*"/>
        <context:property-placeholder location="classpath:config.properties"/>
        <import resource="classpath*:application-cache.xml" />
        <import resource="classpath*:application-spring.xml" />
        <import resource="classpath*:application-mybatis.xml"/>
    </beans>
  • 相关阅读:
    Java设计模式之装饰模式
    学习Emacs系列教程(二):导航
    Android ProgressDialog 延时消失
    java设计模式装饰模式
    Java 字节流和字符流的相互转换
    emacs配置颜色主题
    Android ProgressDialog的使用
    个人管理 时间管理GTD流程图
    jQuery - 列表控件推荐
    WPF - 模板查看工具:Show Me The Template及如何查看第三方主题
  • 原文地址:https://www.cnblogs.com/alice-cj/p/10986265.html
Copyright © 2011-2022 走看看