SPRING-DATA-JPA 全局DAO配置

这篇博客主要介绍了Spring Data JPA的全局DAO配置,包括配置文件spring-jpa.xml的内容,旨在帮助读者理解如何设置和管理DAO层。此外,博主还推荐了一位老师的人工智能教程,该教程适合零基础学习者,讲解生动有趣。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

               

配置文件:spring-jpa.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:p="http://www.springframework.org/schema/p" xmlns:c="http://www.springframework.org/schema/c" xmlns:util="http://www.springframework.org/schema/util" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:jpa="http://www.springframework.org/schema/data/jpa" xsi:schemaLocation="  http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd  http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.1.xsd  http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd  http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa.xsd  http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.1.xsd"> <!--  BoneCP教程见http://www.cnblogs.com/zhwl/archive/2013/07/23/3208550.html -->  <!-- JPA实体管理器工厂 --> <bean id="entityManagerFactory"  class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">  <property name="dataSource" ref="${springJPA.dataSource}" />  <property name="persistenceProvider" ref="persistenceProvider" />  <property name="jpaVendorAdapter" ref="jpaVendorAdapter" />  <property name="jpaDialect" ref="jpaDialect" />  <property name="packagesToScan" value="${springJPA.packagesToScan}" />  <property name="jpaProperties">   <props>    <prop key="hibernate.dialect">org.hibernate.dialect.Oracle9Dialect</prop>    <prop key="hibernate.connection.driver_class">oracle.jdbc.OracleDriver</prop>    <prop key="hibernate.max_fetch_depth">3</prop>    <prop key="hibernate.jdbc.fetch_size">18</prop>    <prop key="hibernate.jdbc.batch_size">10</prop>    <prop key="hibernate.hbm2ddl.auto">${springJPA.jpaProperties.hibernate.hbm2ddl.auto}</prop>    <prop key="hibernate.show_sql">false</prop>    <prop key="hibernate.format_sql">false</prop>    <prop key="javax.persistence.validation.mode">none</prop>    <!-- 查询缓存 -->    <prop key="hibernate.cache.use_query_cache">true</prop>     <prop key="hibernate.cache.region.factory_class">org.hibernate.cache.ehcache.EhCacheRegionFactory</prop>    <!--若为ALL,则默认全部开启二级缓存 ,实体上的@cacheable都不用打-->    <prop key="javax.persistence.sharedCache.mode">ENABLE_SELECTIVE</prop>    <prop key="hibernate.generate_statistics">true</prop>   </props>  </property> </bean>  <!-- 用于指定持久化实现厂商类 --> <bean id="persistenceProvider" class="org.hibernate.ejb.HibernatePersistence" />  <!-- 用于设置JPA实现厂商的特定属性 --> <bean id="jpaVendorAdapter" class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值