2016-10-09 33 views
0

Hibernate和Spring的新手。所以我在網上覆制並粘貼了一些配置,並自己完成了其餘的工作。JPA - 無法找到XML名稱空間的Spring NamespaceHandler [http://www.springframework.org/schema/data/jpa]

但是,當我嘗試啓動我的Jetty服務器時出現Spring錯誤。

無法找到春天NamespaceHandler XML模式命名空間[http://www.springframework.org/schema/data/jpa]

這是什麼意思?

<?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:jpa="http://www.springframework.org/schema/data/jpa" 
     xmlns:repository="http://www.springframework.org/schema/data/repository" 
     xmlns:tx="http://www.springframework.org/schema/tx" 
     xmlns:aop="http://www.springframework.org/schema/aop" 
     xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd 
      http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa.xsd 
      http://www.springframework.org/schema/data/repository http://www.springframework.org/schema/data/repository/spring-repository.xsd 
      http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd"> 


    <jpa:repositories base-package="com.testproject.testpackage.example1.repository" 
         transaction-manager-ref="example1TransactionManager" 
         entity-manager-factory-ref="example1EntityManagerFactory"> 
     <repository:include-filter type="regex" expression=".*Repository"/> 
    </jpa:repositories> 

    <bean id="example1hikariConfig" class="com.zaxxer.hikari.HikariConfig"> 
     <property name="poolName" value="example1Datasource"/> 
     <property name="connectiontestprojectQuery" value="SELECT 1"/> 
     <property name="dataSourceClassName" value="com.mysql.jdbc.jdbc2.optional.MysqlDataSource"/> 
     <property name="minimumIdle" value="5"/> 
     <property name="maximumPoolSize" value="40"/> 
     <property name="idleTimeout" value="2000"/> 

     <property name="dataSourceProperties"> 
      <props> 
       <prop key="url">${db.url}</prop> 
       <prop key="user">${db.username}</prop> 
       <prop key="password">${db.password}</prop> 
      </props> 
     </property> 
    </bean> 
    <bean id="example1Datasource" class="com.zaxxer.hikari.HikariDataSource" destroy-method="close"> 
     <constructor-arg ref="example1hikariConfig"/> 
    </bean> 

    <bean id="hibernate.properties" class="org.springframework.beans.factory.config.PropertiesFactoryBean"> 
     <property name="properties"> 
      <props> 
       <prop key="hibernate.hbm2ddl.auto">validate</prop> 
       <prop key="hibernate.show_sql">${hibernate.showSql}</prop> 
       <prop key="hibernate.format_sql">true</prop> 
       <prop key="hibernate.cache.use_query_cache">false</prop> 
       <prop key="hibernate.cache.use_second_level_cache">false</prop> 
      </props> 
     </property> 
    </bean> 

    <bean id="example1EntityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"> 
     <property name="persistenceUnitName" value="example1"/> 
     <property name="dataSource" ref="example1Datasource"/> 
     <property name="persistenceProviderClass" value="org.hibernate.jpa.HibernatePersistenceProvider"/> 
     <property name="jpaVendorAdapter"> 
      <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"/> 
     </property> 
     <property name="packagesToScan"> 
      <list> 
       <value>com.testproject.testpackage.example1.repository</value> 
      </list> 
     </property> 
     <property name="loadTimeWeaver"> 
      <bean class="org.springframework.instrument.classloading.InstrumentationLoadTimeWeaver"/> 
     </property> 
     <property name="jpaPropertyMap" ref="hibernate.properties"/> 
    </bean> 


    <bean id="example1TransactionManager" class="org.springframework.orm.jpa.JpaTransactionManager"> 
     <property name="entityManagerFactory" ref="example1EntityManagerFactory"/> 
     <qualifier value="example1"/> 
    </bean> 

    <!-- enable the configuration of transactional behavior based on annotations --> 
    <tx:annotation-driven/> 



</beans> 

回答

相關問題