2013-10-07 24 views
6

私は春を使用しています3.2.3.RELEASEと依存関係を引き出すためのmaven。 Eclipseでプロジェクトを構築する場合、次の取得していますエラー:一致するワイルドカードは厳密ですが、要素 'context:component-scan'の宣言が見つかりません

Exception in thread "main" org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 17 in XML document from class path resource [META-INF/spring/application-context.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 17; columnNumber: 64; cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'context:component-scan'. 

マイappication-の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-3.2.xsd 
    http://www.springframework.org/schema/context/ 
    http://www.springframework.org/schema/context/spring-context-3.2.xsd"> 

    <context:component-scan base-package="com.example" /> 

私は私のMavenの依存関係が示すように、正しいjarファイルを引っ張っていますことを知っています::私は私の瓶の中の右スキーマ宣言を持っていることがわかりますMETA-INF/sping.schemasインサイド

Eclipse Maven Dependencies

http\://www.springframework.org/schema/context/spring-context-2.5.xsd=org/springframework/context/config/spring-context-2.5.xsd 
http\://www.springframework.org/schema/context/spring-context-3.0.xsd=org/springframework/context/config/spring-context-3.0.xsd 
http\://www.springframework.org/schema/context/spring-context-3.1.xsd=org/springframework/context/config/spring-context-3.1.xsd 
http\://www.springframework.org/schema/context/spring-context-3.2.xsd=org/springframework/context/config/spring-context-3.2.xsd 
http\://www.springframework.org/schema/context/spring-context.xsd=org/springframework/context/config/spring-context-3.2.xsd 

私も無駄にこれらを見てきました:

Can't load spring 3 schemas

The matching wildcard is strict, but no declaration can be found for element 'tx:annotation-driven'

No declaration can be found for element 'context:component-scan'

The matching wildcard is strict, but no declaration can be found for element 'context:component-scan

助けてください、それは私が狂いそうです。.. .. :(

答えて

14

まず、依存関係を修正する必要があります。あなたはSpring 3.2.3と2.0.6 jarを混在させています(それは起こるのを待っている問題です)。

次はあなたの宣言が間違っていますhttp://www.springframework.org/schema/context/http://www.springframework.org/schema/contextである必要があります。

+0

ありがとうございました。それも見ていない。その最終的な "/"を取り除くと、そのトリックはそれらの依存関係を整理することになります。 – Ithar

+0

同じもの。最後にこの '/'を使って同じチュートリアルをコピー/ペーストする必要があります –

関連する問題