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:annotation-drivenは、コンパイル時エラーを示します。一致するワイルドカードは厳密ですが、要素の宣言が見つかりません。問題を正しく見つけることができませんでした。だから、この問題を見つけるのを手伝ってください。

エラー:cvc-complex-type.2.4.c:一致するワイルドカードは厳密ですが、要素'mvc:annotation-driven'の宣言が見つかりません。何が問題なのか教えていただけますか?

4

2 に答える 2

4

クラスパスにspring-webmvc-*。jarファイルがない可能性があります。

于 2012-07-31T14:33:25.017 に答える
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 を示しているため、実際には @Biju Kunjummen(+1) に従って spring-mvc jar が欠落しているためです。

また、2 つの異なるバージョンの spring-mvc がある場合もあります...

于 2012-07-31T14:37:04.367 に答える