4

私は Spring 3 (3.1.2) と Google App Engine から始めています。

私はチュートリアルをオンラインでフォローしてきましたが、現在、起動中に問題があるBean関連の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.xsd
http://www.springframework.org/schema/context/
http://www.springframework.org/schema/context/spring-context.xsd">
<context:component-scan base-package="my.example">

すべての Java ファイルのルート パッケージは「my.example」です。サブパッケージは、サブパッケージを含む「モデル」と「コントローラー」です。今。

アプリを起動すると、次のエラーが返されます。

org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 10 in XML document from ServletContext resource [/WEB-INF/spring-servlet.xml] is invalid; nested exception is org.xml.sax.SAXParseException: cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'context:component-scan'.

より多くのスタックトレースがあります。

誰も私がこれを解決する方法を知っていますか? XSDをチェックしたところ、正しいようです。

4

3 に答える 3

1

おそらく、コンテキスト スキーマの定義を含む spring-context.jar がありません。

于 2012-07-11T21:47:08.140 に答える
1

これが役立つかどうかはわかりませんが、maven shade プラグインを使用して単一の .jar を作成しているときに、あなたと非常によく似たエラーが発生し、shade プラグインがspring.handlersspring.schemasからMETA-INF/.

このSOの答えは、私を正しい方向に向けました: https://stackoverflow.com/a/3650844/7008

そして、 AppendingTransformer を使用してこれらのスプリングビットをMETA-INF/フォルダーに追加する方法に関するドキュメントは、私にとってはうまくいきました: http://maven.apache.org/plugins/maven-shade-plugin/examples/resource-transformers.html#AppendingTransformer

于 2012-10-03T19:45:59.063 に答える