0

思いつく限りのことを試しましたが、何もうまくいかないようです。

JavaWebアプリケーションで現在のバージョンを使用していSpring Framework (3.2)ます。プロジェクトを開始するたびに、次のエラーが発生します。

cvc-elt.1:要素'beans'の宣言が見つかりません

これは私のapplicationContext.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"
     xsi:schemaLocation="http://www.springframework.org/schema/beans      
               http://www.springframework.org/schema/beans/spring-beans-3.0.xsd"

</beans>

私がしようとしました :

  1. スキーマのバージョンを変更します(3.2、2.0 ...)
  2. スキーマをjarからWEB-INFにコピーします
  3. UNIXのEOLをWindowsのEOLに変更する

XSDの代わりにDTD宣言を使用する以外は、何も機能していないようです。私は何をすべきか?

4

2 に答える 2

0

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-3.0.xsd
         http://www.springframework.org/schema/context
         http://www.springframework.org/schema/context/spring-context-3.0.xsd">

    <context:annotation-config/>
    <context:component-scan base-package="example"/>

</beans>
于 2012-07-04T15:47:09.427 に答える
0

Springはxsdsを見つけるのに問題があります。このSO投稿を見てください。クラスパスに必要なspring-beansjarがあることが確実な場合は、META-INF/spring.schemasファイルが破損している可能性があります。spring.schemasファイルは、Springjar内の対応するxsdファイルを検索するために使用するクラスパスをspringに指示します。不適切に構成されたmaven-shadeプラグインを使用すると、これが発生しました。

于 2012-07-04T16:25:03.703 に答える