2012-01-09 5 views
7

このエラーの原因は何ですか?XMLスキーマ名前空間用のSpring NamespaceHandlerを見つけることができません[http://www.springframework.org/schema/data/jpa]

org.springframework.beans.factory.parsing.BeanDefinitionParsingException: 設定問題: XMLスキーマの名前空間の春NamespaceHandlerを見つけることができません[http://www.springframework.org/schema/data/jpa] 問題のリソース:のServletContextリソース [/WEB-INF/spring/appServlet/servlet-context.xml】ここで

が私の「servle-のcontext.xml」です(インデントのいくつかの問題が、ファイルがありますあまりにも巨大です...):

<?xml version="1.0" encoding="UTF-8"?> 
<beans:beans xmlns="http://www.springframework.org/schema/mvc" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xmlns:tx="http://www.springframework.org/schema/tx" 
xmlns:beans="http://www.springframework.org/schema/beans" 
xmlns:context="http://www.springframework.org/schema/context" 
xmlns:jpa="http://www.springframework.org/schema/data/jpa" 
xsi:schemaLocation="http://www.springframework.org/schema/mvc 
        http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd 
        http://www.springframework.org/schema/beans 
        http://www.springframework.org/schema/beans/spring-beans-3.0.xsd 
        http://www.springframework.org/schema/tx 
        http://www.springframework.org/schema/tx/spring-tx-3.0.xsd 
        http://www.springframework.org/schema/data/jpa 
        http://www.springframework.org/schema/data/jpa/spring-jpa.xsd 
        http://www.springframework.org/schema/context 
        http://www.springframework.org/schema/context/spring-context-3.0.xsd"> 

<!-- DispatcherServlet Context: defines this servlet's request-processing infrastructure --> 

<!-- Enables the Spring MVC @Controller programming model --> 
<annotation-driven /> 

<!-- Handles HTTP GET requests for /resources/** by efficiently serving up static resources in the ${webappRoot}/resources directory --> 
<resources mapping="/resources/**" location="/resources/" /> 

<!-- Resolves views selected for rendering by @Controllers to .jsp resources in the /WEB-INF/views directory --> 
<beans:bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"> 
    <beans:property name="prefix" value="/WEB-INF/views/" /> 
    <beans:property name="suffix" value=".jsp" /> 
</beans:bean> 

<context:component-scan base-package="com.epam.mvc3.model" /> 
<context:component-scan base-package="com.epam.mvc3.controller" /> 

<!-- JPA --> 
<beans:bean 
    class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> 
    <beans:property name="location"> 
     <beans:value>resources/database.properties</beans:value> 
    </beans:property> 
</beans:bean> 

<beans:bean id="myDataSource" 
    class="org.springframework.jdbc.datasource.DriverManagerDataSource"> 
    <beans:property name="driverClassName"> 
     <beans:value>${jdbc.driverClassName}</beans:value> 
    </beans:property> 
    <beans:property name="url"> 
     <beans:value>${jdbc.url}</beans:value> 
    </beans:property> 
    <beans:property name="username"> 
     <beans:value>${jdbc.username}</beans:value> 
    </beans:property> 
    <beans:property name="password"> 
     <beans:value>${jdbc.password}</beans:value> 
    </beans:property> 
</beans:bean> 

<beans:bean id="myEmf" 
    class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"> 
    <beans:property name="dataSource" ref="myDataSource" /> 

    <beans:property name="persistenceUnitName" value="application" /> 
    <beans:property name="persistenceXmlLocation" 
     value="classpath*:META-INF/persistence.xml" /> 
    <beans:property name="jpaVendorAdapter" ref="hibernateVendor" /> 

    <beans:property name="loadTimeWeaver"> 
     <beans:bean 
      class="org.springframework.instrument.classloading.InstrumentationLoadTimeWeaver"></beans:bean> 
    </beans:property> 
</beans:bean> 

<beans:bean id="hibernateVendor" 
    class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"> 
</beans:bean> 

<beans:bean id="transactionManager" 
    class="org.springframework.orm.jpa.JpaTransactionManager"> 
    <beans:property name="entityManagerFactory" ref="myEmf"></beans:property> 
</beans:bean> 

<tx:annotation-driven transaction-manager="transactionManager" /> 

<!-- Spring Data configuration --> 
<jpa:repositories base-package="com.epam.mvc3.repository"/> 

</beans:beans> 

ご覧のとおり、私はjpa-schemaへのパスを指定しました。そして、私は問題

+0

あなたのXMLの完全なヘッダーを投稿してください。 – Kai

+0

完了しました...... – Eugene

+0

クラスパスにSpring Data jarがあることを確認してください。 – axtavt

答えて

3

http://www.springframework.org/schema/data/jpa/spring-jpa-1.0.xsd

によって

http://www.springframework.org/schema/data/jpa/spring-jpa.xsd

を交換してみているのか分からないしかし、あなたはまだ最初の更新しようとし、その後バージョン1.0-M1を使用している場合。 DATAJPA-21

+0

これは受け入れられる回答ですが、私にとってこの問題は解決しませんでした。私はspring-data-jpa 1.2.0.RELEASEを使用し、残りのSpring Jarは3.1.3.RELEASEです。spring-data-commons-coreに関して - 私は自分のpomに依存していませんが、私はsq-data-commons-parentとバージョン1.4.0の両方の私のm2リポジトリで見ることができます。なぜか分かりません(おそらくそれらはスプリングデータの一部です)。新しい洞察? – forhas

+0

@forhas:この継ぎ目は別の質問であること。だから新しいスタックオーバーフローの質問(あなたのProbelem、設定と例外、あなたがそのように運賃を持っているものを記述してください)を作成し、おそらくここにコメントとして質問にリンクを残してください。 – Ralph

+0

ありがとうラルフ、私はそれを行います。 – forhas

0

spring-jpaスキーマを見つけることができないためです。スキーマ情報が含まれていない古い瓶があるかもしれません。

+0

私は、 "hibernate-core-3.6.3.Final.jar"、 "hibernate-jpa-2.0-api-1.0.0.Final.jar"、 "spring-data-commons-core-1.1.0 .RELEASE.jar "、" spring-orm-3.0.5.RELEASE.jar "彼らは時代遅れだと思いますか? – Eugene

+0

@Eugeneあなたはspring-jpa名前空間を使用しています - あなたはspring-jpa jarを持っていませんか?あなたは[ここ](http://mirrors.ibiblio.org/pub/mirrors/maven2/org/springframework/spring-jpa/)を見つけることができます。 –

1

私は、このプロジェクトのspring-tx依存関係の欠落を解決することでこれを解決しました。

org.springframework:春-TX

0

私は、これは愚かなようだけど、あなたはIDEAとMavenを使用している場合は、サーバはまたあなたへのアクセス権を持つようにあなたが使うプラグインレジストリをチェックしていることを確認するチェックする必要がありますjarファイル。

私はスクリーンショットを投稿しますが、私はここで新しく、十分な評判ポイントを持っていません。あなたはMavenを使用する場合は、あなたの依存関係に

をバネ - データJPAを持っていることを確認してくださいこれは、しかし仕事をして、私はIntelliJの

2

でのサポートチームで確認しました:

<dependency> 
    <groupId>org.springframework.data</groupId> 
    <artifactId>spring-data-jpa</artifactId> 
    <version>1.7.0.RELEASE</version> 
</dependency> 
0

これに直面した後、同じ問題が1週間で解決しました。あなたが遅すぎる

<?xml version="1.0" encoding="windows-1252"?> 
<beans xmlns="http://www.springframework.org/schema/beans" 
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
     xmlns:p="http://www.springframework.org/schema/p" 
     xmlns:context="http://www.springframework.org/schema/context" 
     xmlns:mvc="http://www.springframework.org/schema/mvc" 
     xmlns:aop="http://www.springframework.org/schema/aop" 
     xmlns:tx="http://www.springframework.org/schema/tx" 
     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 
     http://www.springframework.org/schema/mvc 
     http://www.springframework.org/schema/mvc/spring-mvc.xsd 
     http://www.springframework.org/schema/aop 
     http://www.springframework.org/schema/aop/spring-aop.xsd 
     http://www.springframework.org/schema/tx 
     http://www.springframework.org/schema/tx/spring-tx.xsd"> 

    <!-- Use @Component annotations for bean definitions --> 
    <context:component-scan base-package="PACKAGE WHERE YOU CAN FIND YOUR SOURCE CODE"/> 

    <!-- Use @Controller annotations for MVC controller definitions --> 
    <mvc:annotation-driven /> 

    <!-- Add JPA support --> 
    <bean id="emf" class= 
      "org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"> 
     <property name="loadTimeWeaver"> 
      <bean class= 
          "org.springframework.instrument.classloading.InstrumentationLoadTimeWeaver"/> 
     </property> 
    </bean> 

    <!-- Add Transaction support --> 
    <bean id="transactionManager" 
      class="org.springframework.orm.jpa.JpaTransactionManager"> 
     <property name="entityManagerFactory" ref="emf"/> 
    </bean> 

    <!-- Use @Transaction annotations for managing transactions --> 
    <tx:annotation-driven transaction-manager="transactionManager" /> 

    <!-- View resolver --> 
    <bean class= 

<!-- HERE YOU REPLACE PROPERTY VALUE TO MATCH YOUR VIEW FOLDER (JSP PAGES) --> 
        "org.springframework.web.servlet.view.InternalResourceViewResolver"> 
     <property name="prefix" value="/web/"/> 
     <property name="suffix" value=".jsp"/> 
    </bean> 

</beans> 
0

このディスパッチャ-servlet.xmlを使用し、Spring MVCの+ JPA + Mavenを使用しているが、これは私の問題を解決した場合:

<dependency> 
    <groupId>org.springframework.data</groupId> 
    <artifactId>spring-data-jpa</artifactId> 
    <version>1.9.4.RELEASE</version> 
</dependency>