SpringMVC:no declaration can be found for element 'mvc:annotation-driver'和 'context:component-scan'.

来源:互联网 发布:2017网络流行词语大全 编辑:程序博客网 时间:2024/06/08 05:13

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

解决办法:
beans 中增加绿色部分的context、spring-context。  具体引用可查看spring-context-4.3.5.RELEASE.jar下的META-INF/spring-schemas文件。
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:context="http://www.springframework.org/schema/context"
    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.xsd
   http://www.springframework.org/schema/context
    http://www.springframework.org/schema/context/spring-context.xsd">
      
配置: <context:component-scan base-package="com.demo.controller" />

问题二:  
        1、cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'mvc:annotation-driver'.
解决办法:增加如下绿色部分XML schemes
        2、cvc-complex-type.2.4.c: 通配符的匹配很全面, 但无法找到元素 'mvc:annotation-driven' 的声明。

<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"   
    xmlns:mvc="http://www.springframework.org/schema/mvc"
    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 
    http://www.springframework.org/schema/mvc
    http://www.springframework.org/schema/mvc/spring-mvc.xsd">

    <mvc:annotation-driven />


阅读全文
0 0