2012-07-31 61 views
2
<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" 
    xmlns:aop="http://www.springframework.org/schema/aop" 

    xsi:schemaLocation=" 
         http://www.springframework.org/schema/beans 
         http://www.springframework.org/schema/beans/spring-beans.xsd 

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

http://www.springframework.org/schema/aop 
         http://www.springframework.org/schema/aop/spring-aop.xsd" 
         > 

这是我的模式声明。但mvc:注解驱动它显示编译时错误。 匹配的通配符是严格的,但是对于元素没有声明。我无法正确地找到问题。所以请帮助找到这个问题。<mvc:annotation-driven />显示编译时错误

错误: cvc-complex-type.2.4.c:匹配通配符是严格的,但是对于元素'mvc:annotation-driven'没有声明。 你能告诉我什么是问题吗?

+0

这个标签会显示错误......但豆类架构它不显示任何错误。所以请看看这个。给解决方案.. – Vicky 2012-07-31 14:31:24

回答

4

您可能在类路径中缺少spring-webmvc - *。jar文件。

+0

我给所有春季网站罐...但仍然错误显示.. – Vicky 2012-08-01 07:08:01

0

刚刚创建的:

<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" 
    xmlns:aop="http://www.springframework.org/schema/aop" 

    xsi:schemaLocation=" 
        http://www.springframework.org/schema/beans 
        http://www.springframework.org/schema/beans/spring-beans.xsd 

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

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

和琐碎的代码

public static void main(String[] args) { 
    System.out.println(new ClassPathXmlApplicationContext("1.xml").getBeanDefinitionCount()); 
} 

这说明0没有错误,所以实际上这是因为缺少春天-mvc jar根据@Biju Kunjummen (+1)

你也可以有2个不同版本的弹簧MVC的...

+0

org.springframework.web-3.0.6.RELEASE.jar,org.springframework.web.servlet-3.0.6.RELEASE.jar但我有这两个罐子......这就够了。 right .. – Vicky 2012-07-31 15:18:07

+0

我不确定什么是spring-web-servlet,但你需要添加这个http://search.maven.org/remotecontent?filepath=org/springframework/spring-web/3.0.6.RELEASE /spring-web-3.0.6.RELEASE.jar – 2012-07-31 16:43:56

+0

当我运行这个主要方法时,我在线程“主线程”org.springframework.beans.factory.BeanDefinitionStoreException中得到异常。即使我给了绝对路径...... – Vicky 2012-08-01 07:07:15